while($a<1000){
$a++;
foo();
}
If foo() consumes a lot of resources, needs to be connected to the Internet, needs to add, delete, modify and check many databases, etc., do we have to wait for foo() to finish executing before starting the next cycle?
滿天的星座2017-05-16 13:17:15
Execution rights issue in yes.php..
Only after the function is executed, the execution right will be returned to the calling place and the following code will continue to be executed.
滿天的星座2017-05-16 13:17:15
The next loop will not be executed until the foo function is executed. PHP is a single-process blocking execution. Asynchronous execution requires swoole extension, or use pcntl extension to implement multi-process under Linux, and put time-consuming operations into sub-processes for execution. You can use pthreads extension to implement multi-threading, but it must be executed under the TS version of PHP