Using include() to Execute PHP and Assign the Return Value : include « Utility Function « PHP






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

 
<html>
<head>
<title>Acquiring a Return Value with include()</title>
</head>
<body>
<div>
<?php
$addResult = include("another.php");
print "The include file returned $addResult";
?>
</div>
</body>
</html>


//An Include File That Returns a Value
//another.php

 <?php
 $retval = ( 4 + 4 );
 return $retval;
 ?>
  
  








Related examples in the same category

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