dcc dcc - 1 month ago 7
PHP Question

Does PHP sequentially process includes

I have separate php files that I have running on my linux server in separate cron jobs. I'd like to consolidate them into one cron job that calls a single php file with multiple php includes, and run them sequentially. Each include must wait to process until the prior is completed. Is this the behavior of how php processing of server-side includes occurs (note: there is no html involved here)? If not, is there a suggested alternative?

Answer

Yes, if you include them one after one, like this:

include 'a.php';
include 'b.php';
include 'c.php';

...then yes, b.php won't start until a.php hasn't completely finished its job
This is just how PHP works - line after line.

Comments