gpt4 book ai didi

php - PHP 上的 shell_exec 和 exec 没有返回字符串

转载 作者:搜寻专家 更新时间:2023-10-31 20:51:03 24 4
gpt4 key购买 nike

这段代码让我很头疼:

$data = shell_exec("wget -S --spider http://dkphp.com");
echo "Encoded:" .$data;

$data 为“NULL”

我不知道为什么,它支持回显类似 :( 今天花了大约 5 个小时,它仍然是 NULL :(

HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Date: Thu, 29 Sep 2011 01:31:45 GMT
Server: LiteSpeed
Connection: close
X-Powered-By: PHP/5.3.8
Set-Cookie: PHPSESSID=50781d657c7632cc1b2e7536d5fa0c50; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
Pragma: no-cache
content: text/html
Content-Type: text/html
Length: unspecified [text/html]
200 OK

最佳答案

我在 PHP 的交互模式下检查了你的代码片段(php -a 来自命令行)

wget 将该信息打印到 STDERR,而不是 STDOUT。

这个有效:

$data = shell_exec("wget -S --spider http://dkphp.com 2>&1");
echo "Encoded:" .$data;

关于php - PHP 上的 shell_exec 和 exec 没有返回字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7591516/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com