So, I have a sidebar.php that is included in the index.php. Under a certain condition, I want sidebar.php to stop running, so I thought of putting exit in sidebar.php, but that actually exits all the code beneath it meaning everything beneath include('sidebar.php'); in index.php all the code would be skipped as well. Is there a way to have exit only skip the code in the sidebar.php?
So, I have a sidebar.php that is included in the index.php . Under a
Share
Just use
return;Do also be aware that it is possible to actually return something to a calling script in this way.
if your parent script has
$somevar = include("myscript.php");and then in myscript.php you do say…return true;you will get that value in$somevar