开发者

shell_exec and exec on PHP didn't return string

开发者 https://www.devze.com 2023-04-08 07:36 出处:网络
I got headache by this code: $data = shell_exec(\"wget -S --spider http://dkphp.com\"); echo \"Encoded:\" .$data;

I got headache by this code:

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

$data is "NULL"

I don't know why, its support to echo something like :( Spend like 5 hours tod开发者_JS百科ay, and its still 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


I checked your code snippet in PHP's interactive mode (php -a from the command line)

wget prints that information to STDERR, not STDOUT.

This works:

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

精彩评论

暂无评论...
验证码 换一张
取 消