How can I tell if return() was called from within the included file. The problem is that include() returns 'int 1', even if return() wasn't called. Here is an example...
included_file_1.php
<?php
return 1;
included_file_2.php
<?php
echo 'no return here, meep';
main.php
<?php
$ret = include('included_file_1.php');
// This file DID return a value, int 1, but include() returns this value even if return() wasn't called in the included file.
if ($ret === 1)
{
echo 'file did not return anything';
}
var_dump($ret);
$ret = include('included_file_2.php');
// The included file DID NOT return a value, but include() returns 'int 1'
if ($ret === 1)
{
echo 'file did not return anything';
}
var_dump($ret);
Edit: As a temporary solution, I'm catching the output from include() (from echo/print statements). If any output was produced, I ignore the return value from include().
Not pretty, but it provides the functionality I need in my web app/framework.