异步PHP? [英] Asynchronous PHP?

查看:22
本文介绍了异步PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 PHP 脚本,它会进行大量检查,然后将文件下载到服务器并输出原始文件.
下载我使用的文件

I have a PHP script that does a lot of checks and then downloads a file to the server and outputs the original.
To download the file I use

system("/usr/local/bin/wget -O ...");

所以 php 等待下载完成,然后输出文件.
我的问题是是否可以在某处(其他 php 文件?)发送ping"以开始下载,然后不等待结果就继续执行.

So php waits for the download to finish and then it outputs the file.
My question is if its possible to send a "ping" somewhere (other php file?) for the download to start and then without waiting for the result just continue with the execution.

推荐答案

使用 curl_multi_* 函数并行处理多个下载.PHP 缺乏任何类型的线程支持,进程分叉只是一个黑客.

Use curl_multi_* functions to handle multiple-downloads in parallel. PHP lacks any kind of threading support and process forking is merely a hack.

这篇关于异步PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆