use Socket;
$host="xxx.xxx.xxx.xxx."; (XXX.xxxx.xxxx.xxx) Type here your ip
print("Scan $host:\n");
for($i=0; $i<65000; $i++){ ( Type here what ports do you want to scan )
socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
$iaddr = inet_aton($host);
$paddr = sockaddr_in($i, $iaddr);
if(connect(SOCK, $paddr)){
print("$i - OK\n");
}else{
print("$i - NO\n");
}
}