I have a php script example1.php
How would the control flow be when I call another php script example2.php from example1.php.
E.g example1.php looks like this
....
...
....
shell_exec("php -q example2.php") (calling example2.php from example1.php)
.....
.....
How does the control flow work for this ? Does example1.php wait until example2.php completes execution and then continious with rest of code logic or does it just continues allowing example2.php to run independently ?
Thanks !
shell_exec()
executes the shell command and waits for it to finish. The fact that the command you're running is php
is irrelevant.
if you have test1.php:
echo "test1";
include("test2.php");
echo "test3";
and test2.php
for ($i = 1; $i <= 10000; $i++) {
}
echo "test2";
Your result will be: test1 test2 test3
However, the code after include will be execute after include process finish.