Functie Ping IP in PHP

Acum ceva vreme aveam nevoie sa dau ping unui ip din PHP fara a avea un VPS sau Dedicat, asa ca am cautat un serviciu care ofera aceasta optiune si am codat o functie in acest sens. Aceasta verifica daca un ip este sau nu online. Sper sa va fie de folos! 🙂

<?php
function verifica($ip)
{
$da=file_get_contents("http://www.ajaxutils.com/ping/ajax.php?query=$ip");

$findme   = ', 0 received';
$pos = strpos($da, $findme);
if ($pos !== false) {
     return 'Offline';
} else {
     return 'Online';
}
}
echo verifica('127.0.0.1');
?>




Silviu Stroe

Silviu is a full stack developer and entrepreneur. He is the founder of one of the first VPN services in Romania, RoTunneling and is part of Yahoo - Wall of Fame. He also loves bleeding edge technologies and new challenges.

No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *