note 79605 added to function.fsockopen
| From: | landerretche at free dot fr | Date: | Wed, 05 Dec 2007 10:59:13 +0000 |
| Subject: | note 79605 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132842@lists.php.net to get a copy of this message | ||
Make a ping test with PHP
The problem with fsockopen is you have to known the destination port.
A real ping function could be :
function php_ping($url) {
$addr=parse_url($url);
$host=$addr['host'];
exec("ping -c 1 -w 1 $host", $list);
if (strpos($list[4],"1 received")>0) {
return true ;
}
return false;
}
But if your router refuse the ping ... the result will be always false > you may test both
(fsockopen and ping)
----
Server IP: 195.221.21.36
Probable Submitter: 62.147.138.93
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- https://master.php.net/note/edit/79605
Del: integrated -- https://master.php.net/note/delete/79605/integrated
Del: useless -- https://master.php.net/note/delete/79605/useless
Del: bad code -- https://master.php.net/note/delete/79605/bad+code
Del: spam -- https://master.php.net/note/delete/79605/spam
Del: non-english -- https://master.php.net/note/delete/79605/non-english
Del: in docs -- https://master.php.net/note/delete/79605/in+docs
Del: other reasons-- https://master.php.net/note/delete/79605
Reject -- https://master.php.net/note/reject/79605
Search -- https://master.php.net/manage/user-notes.php