• 10Nov

    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.
    You need flash to play this tutorial.
    This tutorial goes over the following goals:
    Showing how you order things really matters
    Including multiple files may overwrite some variables
    Manage your variables wisely.
    You can find this tutorial video on youtube here.

    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";
    
    ?>

    Here are all the php functions used in this tutorial:

    Posted by Kloplop321 @ 7:14 pm

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.