You can use the operator returnto exit the included file and optionally return a value.
Example:
<?php
$value = include('file2.php');
echo $value;
Including:
<?php
// file2.php:
if($_REQUEST['something'] == 'something else')
return 'Something else';
//do some stuff if _REQUEST['something'] != 'something else'
return 'something';
Obviously, this is a useless example, but it demonstrates use returnfor the include()ed file .
source
share