在PHP中是否有其他类型的获取远程数据,除了:"cURL"
并且 php.ini 中的"allow_url_fopen"
设置为"On"
,能够使用"fopen"
,"fsockopen"
或"file_get_contents"
流式传输远程内容吗?
我正在开发自定义PHP远程内容流媒体,如果"cURL"
或"allow_url_fopen"
为"Off"
,我正在寻找其他任何流式传输远程内容的方式。< / p>
答案 0 :(得分:1)
运行系统调用怎么样?与passthru()
或exec()
或system()
一样,并在命令行上调用curl
或wget
并捕获数据
Linux示例:
ob_start();
passthru("wget -U 'CustomUserAgent' -q -O - 'http://www.example.com/'");
$output = ob_get_clean();
Windows 7+示例(通过powershell)。取自here
(new-object System.Net.WebClient).DownloadFile('http://www.example.come','C:\tmp\output.txt') –
要展开Windows方法,请参阅executing a Powershell script from php
答案 1 :(得分:1)
“allow_url_fopen”不会影响“fsockopen”。
即使这样做,在网络服务器中启用系统调用也是比“allow_url_fopen = On”更大的安全威胁。
要禁用fsockopen,可将其添加到php.ini中的“disable_functions”