问题描述
我要尝试的操作方法是:我有一个php文件,让我们调用trigger.php
,该文件运行一些php代码,该代码会触发另一个php文件,我们将调用backgroundProcess.php
开始处理
What I'm trying to work out how to do is this: I've got a php file let's call trigger.php
that runs some php code that sets off another php file we'll call backgroundProcess.php
to start processing.
尽管trigger.php
需要忽略backgroundProcess.php
所发生的情况,但它只需要启动它即可处理,并且会在backgroundProcess.php
继续运行时停止.
Although trigger.php
needs to ignore what happens to backgroundProcess.php
, it just has to start it processing and it will stop while backgroundProcess.php
keeps going.
edit1
我正在Windows Wampserver 2.1上运行它,所以这必须是Windows命令.
I'm running this on Windows Wampserver 2.1 So this has to be a windows command.
edit2
感谢jakenoble的建议,使用以下命令解决了该问题:
Solved it with the following command, thanks to jakenoble's suggestions:
exec("C:\wamp\bin\php\phpVERSION_NUMBER\php.exe -f C:\wamp\www\path\to\backgroundProcess.php");
推荐答案
您可以使用exec()
并将&
添加到调用的末尾,以及输出流:
You can use exec()
and add an &
to the end of the call, plus an output stream:
在trigger.php
In trigger.php
exec("php backgroundProcess.php > /dev/null &");
您可以在此处找到更多信息 http://php.net/manual/zh/function.exec.php
You can find out more here http://php.net/manual/en/function.exec.php
这篇关于使用php触发另一个php脚本,然后忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!