To help personalise content and provide a safer experience, we use cookies. By clicking or navigating the site, you agree to our cookie policy.

There maybe times when you need to run another PHP script from within a PHP script.

I think we need an example:

We have a PHP script that runs every day which we will call: dailyscript.php

In this script we would like to make sure a friend gets an email to let them know that the script has run, instead of having the email code in this script we have a separate one called: emailscript.php

We would like dailyscript.php to invoke emailscript.php at some point in the script.

In dailyscript.php add:

exec(“php-cli /path/folder/emailscript.php“);

This will do it!

If however you would like the results of the emailscript.php (maybe it echo’s DONE!) you can use this command: