Skip to content
Advertisement

The shutdown function in the main php script is not executing when I call exit() from included script

I have a main.php script which include another script named inc.php. When I call exit function from the inc.php, the main.php dies without executing the function registered as a shutdown function. Like:

main.php

JavaScript

inc.php

JavaScript

running main.php will return

JavaScript

But I was expecting

JavaScript

what is wrong?

Advertisement

Answer

The function must be registered before exit.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement