check if a service exists on a port

check if a service exists ona port using PEAR NET_Portscan package

<?php
require_once "/Net/Portscan.php";

if (Net_Portscan::checkPort("localhost", 80) == NET_PORTSCAN_SERVICE_FOUND)
{
echo "Service exists on port 80 (" . Net_Portscan::getService(80) . ").\n";
}
?>