PHP/Language Basics/Include

Материал из Web эксперт
Перейти к: навигация, поиск

Test of PHP Includes

   <source lang="html4strict">


<html> <head> <title> Test of PHP Includes </title> </head> <body> <?php

 include("include-me.php");

?> </body> </html>

      </source>
   
  


Using include()

   <source lang="html4strict">

<html> <head> <title>Using include()</title> </head> <body> <?php include("myIncludeFile.php"); ?> </body> </html>


      </source>
   
  


Using include() to Execute PHP and Assign the Return Value

   <source lang="html4strict">


<html> <head> <title>Using include() to execute PHP and assign the return value</title> </head> <body> <?php

   $addResult = include("myIncludeFileWithReturnValue.php");
   print "The include file returned $addResult";

?> </body> </html>


      </source>
   
  


Using include() Within a Loop

   <source lang="html4strict">

<html> <head> <title>Using include() within a loop</title> </head> <body> <?php for ( $x = 1; $x<=3; $x++ ) {

  $incfile = "incfile$x".".txt";
  print "Attempting include $incfile
"; include( "$incfile" );
print "

"; } ?> </body> </html> </source>