wget 404 hatası karşı karşıya olmadığını decect nasıl php?

3 Cevap php

I'm running wget through php's shell_exec() How could I understand that wget got 404 error getting file?

Teşekkür ederim.

3 Cevap

Ben yanlış problem çözme düşünüyorum. David İlk Yorum önerilen ayrıştırmak-mümkün statüsünü, anlamlı ile portably başarısız olamaz bir şey kullanmadan önce CURL deneyin.

Sen ile aşağıdaki gibi bir komut satırını kullanın exec yapabilirsiniz:

exec("wget http://www.google.com/not_present.html 2> some_temp_file ",&output,&retvalue);

Bir hata oluştu görmek için retvalue edin. Sıfır olmayan bir değer hata oluştu demektir. Biz standart hatayı yönlendirilir beri some_temp_file, sen desen için bu dosyayı grep olabilir 404 Not Found. Mevcut olduğu takdirde, bir 404 oluştuğunu gösterir.