I have one simple PHP file which I am running from command line like
php my-file.php
and its working fine without any issue. I want run another file when some event happen like below
<?php
echo " hello this is sample";
exit();
// I want run another file here after exit command called
next-file.php
echo "next-file is successfully running";
?>
Let me know if someone can give idea how can I achieve this? Thanks
Use include_once 'next-file.php'; to import and run the code.
Then related to PHP Doc, here is the definition of exit():
Terminates execution of the script. Shutdown functions and object destructors will always be executed even if exit is called.
So add this code line into the shutdown function as below:
function shutdown()
{
include_once 'next-file.php';
echo "next-file is successfully running", PHP_EOL;
}
register_shutdown_function('shutdown');
Be sure to record this function before the exit().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With