In this tutorial, I go over how including multiple files could be problematic if you are using the same variable names. You will see in the following video. Also, you may need to change the code when copying the the files down as some of them are in different locations.
Here are the sources used in this tutorial:
include.php
<?php $x+=1; echo "Hey you included me! Take a look in the main file, do you see me? $x <br />\n"; ?>
tut015.php
<?php //PHP Tutorial 015 $x = 0; include("../shared/shirtslong.php"); include("../shared/shirts.php"); print_r($shirts); echo $x; ?>
shirtslong.php
<?php //This is a long list of shirt sizes. $shirts = array(); $shirts[] = "XXS"; $shirts[] = "XS"; $shirts[] = "S"; $shirts[] = "M"; $shirts[] = "L"; $shirts[] = "XL"; $shirts[] = "XXL"; $shirts[] = "XXXL"; $shirts[] = "XXXXL"; $x+=2; ?>
shirts.php
<?php //This is a short standard list of shirt sizes. $shirts = array(); $shirts[] = "XS"; $shirts[] = "S"; $shirts[] = "M"; $shirts[] = "L"; $shirts[] = "XL"; ?>