Return from include file

Viewed 66430

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();
}
5 Answers

I know that this has already been answered, but I think I have a nice solution...

main.php

function test()
{
    $data = 'test';
    ob_start();
        include( dirname ( __FILE__ ) . '/included.php' );
    return ob_get_clean();
}

included.php

<h1>Test Content</h1>
<p>This is the data: <?php echo $data; ?></p>

I just included $data to show that you can still pass data to the included file, as well as return the included file.

Related