Including Other Files : include « Utility Function « PHP






Including Other Files

 
//foo.php:

    <?php
            print "Starting foo\n";
            include 'bar.php';
            print "Finishing foo\n";
    ?>


//bar.php:

    <?php
            print "In bar\n";
    ?>


After including foo.php would look like this:

    <?php
            print "Starting foo\n";
            print "In bar\n";
            print "Finishing foo\n";
    ?>
  
  








Related examples in the same category

1.Behavior of Files Included Using include
2.Including files relative to the current file
3.Using include to Load Files in PHP
4.Using include() Within a Loop
5.Using include() to Execute PHP and Assign the Return Value