syntax for php require code example
Example 1: require in php
// Require a file to be imported or quit if it can't be found
<?php
require 'requiredfile.php';
?>
Example 2: echo require php
return.php
<?php
$var = 'PHP';
return $var;
?>
noreturn.php
<?php
$var = 'PHP';
?>
testreturns.php
<?php
$foo = include 'return.php';
echo $foo;
$bar = include 'noreturn.php';
echo $bar;
?>
//$bar is the value 1 because the include was successful. Notice the difference between the above examples. The first uses return within the included file while the other does not. If the file can't be included, false is returned and E_WARNING is issued.