If i use "return" outside a function in an included php file PHP skips the rest of the file.
Can i do this from inside a function?
test1.php:
<?php
echo 'test1';
include('test2.php');
echo 'test2'
?>
test2.php
<?php
function returner()
{
return_included_file;
}
returner();
//I don't want this to be executed
echo 'test';
?>
desired output:
test1
test2
Put an exit
there
<?php
function returner()
{
return_included_file;
}
returner();
exit; // here...
//I don't want this to be executed
echo 'test';
?>
if(!returner())
{
echo 'test';
}
You could do this:
<?php
function returner()
{
return_included_file;
}
return returner();
//I don't want this to be executed
echo 'test';
?>
By doing so echo 'test';
will not be executed.