标签:php
假设有两个PHP函数.
function first()
{
$keyword = $this->input->post('keyword');
//search for the result and show it to users.
$this->search->search($keyword);
//send the keyword to save it into the db.
$this->second($keyword);
}
function second($keyword)
{
//saving a search keyword in the db
}
我想尽快发送结果,并将搜索词保存到数据库中.
但是,我想在特定时间之后再运行第二个脚本.
因为我想将搜索结果尽快提供给客户.
用户运行第一个PHP脚本后,是否可以运行第二个PHP脚本?
* I don't want to use Cron Job
* I wanna run those two script separatly.
* don't want to use sleep because it will stop the first script for certain times.
解决方法:
您需要将其路由回您的服务器,但是这种异步php方法的效果很好(我已经使用它大约一年了,几乎可以完成您似乎正在做的事情).
标签:php
来源: https://codeday.me/bug/20191101/1981373.html