本文介绍了如何从一个又一个的PHP脚本异步运行PHP脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
Call另一个PHP脚本,并将控制返回给用户其他的脚本完成之前的
我需要从另外一个PHP脚本异步运行的PHP脚本。
I need to run a PHP script from another PHP script asynchronously.
<?php
echo "Entering main script 1";
system("php script2.php");
echo "Exiting main script 1";
?>
脚本2
<?php
echo "Entering script 2";
sleep(10);
echo "Exiting script 2";
?>
在的脚本1 的,我使用系统()方式来运行的的 script2.php 的。我不想脚本1等待2脚本来完成它的执行。如何使它异步?是否有任何其他的方法来运行,而无需使用system()函数在PHP脚本?请帮帮我。谢谢你。
In script 1, I use system() method to run script2.php. I dont want script 1 to wait for script 2 to complete its execution. How to make it asynchronous? Is there any other method to run a PHP script without using system() function? Please help me. Thanks.
推荐答案
添加&安培;
到命令行的末尾,使这一进程在后台运行对绝大多数的炮弹。即:
Add an &
to the end of the command-line to make the process run in the background on the vast majority of shells. i.e.:
脚本1
<?php
echo "Entering main script 1";
system("php script2.php &");
echo "Exiting main script 1";
?>
这篇关于如何从一个又一个的PHP脚本异步运行PHP脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!