J’ai eu mal à la tête avec ce code:
$data = shell_exec("wget -S --spider http://dkphp.com"); echo "Encoded:" .$data;
$ data est “NULL”
Je ne sais pas pourquoi, son support pour faire écho à quelque chose comme 🙁 Passez comme 5 heures aujourd’hui, et c’est toujours 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
J’ai vérifié votre extrait de code en mode interactif de PHP ( php -a
depuis la ligne de commande)
wget imprime ces informations sur STDERR, pas sur STDOUT.
Cela marche:
$data = shell_exec("wget -S --spider http://dkphp.com 2>&1"); echo "Encoded:" .$data;