Not. die is an alias for exit , which immediately stops script execution.
But you can use return , which does exactly what you want:
When called from a global scope, execution of the current script file ends. If the current script file was include() ed or require() ed, then control is transferred back to the calling file. Also, if the current script file was include() ed, then the value specified in return() would be returned as the value of the include() call. If return() is called from the main script file, then the script terminates.
As stated in the excerpt from the PHP documentation , you can even use it to return the return code / return value from include:
$include_retval = include('file_like_function.php'); if ($include_retval) { die("include returned error code: " . $include_retval); }
source share