Return from include file

in PHP, how would one return from an included script back to the script where it had been included from?

IE:

1 - main script 2 - application 3 - included

Basically, I want to get back from 3 to 2, return() doesn't work.

Code in 2 - application

$page = "User Manager";
if($permission["13"] !=='1'){
    include("/home/radonsys/public_html/global/error/permerror.php");
    return();
}

Solution 1:

includeme.php:

$x = 5;
return $x;

main.php:

$myX = require 'includeme.php'; 

also gives the same result

This is one of those little-known features of PHP, but it can be kind of nice for setting up really simple config files.

Solution 2:

return should work, as stated in the documentation.

If the current script file was include()ed or require()ed, then control is passed back to the calling file. Furthermore, if the current script file was include()ed, then the value given to return() will be returned as the value of the include() call.