0
爲什麼strpos PHP
不適用於fsockopen響應?爲什麼strpos PHP不能與fsockopen響應一起工作?
當負載此代碼。該代碼將請求sdgsgsdgsfsdfsd.ca
到whois.cira.ca
服務器和查找文本Domain status: available
與strpos PHP
如果發現它的將是回聲
{"domain":"sdgsgsdgsfsdfsdca","availability":"available"}
,但如果沒有找到的文本。它將會呼應
{"domain":"sdgsgsdgsfsdfsdca","availability":"TAKEN"}
在這種情況下found text
但仍然呼應
{"domain":"sdgsgsdgsfsdfsdca","availability":"TAKEN"}
我該怎麼辦?
<?php
$server = "whois.cira.ca";
$response = "Domain status: available";
showDomainResult(sdgsgsdgsfsdfsd.ca,$server,$response);
function checkDomain($domain_check,$server,$findText)
{
$con = fsockopen($server, 43);
if (!$con) return false;
fputs($con, $domain_check."\r\n");
$response = ' :';
while(!feof($con))
{
$response .= fgets($con,128);
}
echo $response."<BR><BR><BR><BR><BR>";
fclose($con);
if (strpos($response, $findText))
{
return true;
}
else
{
return false;
}
}
function showDomainResult($domain_check,$server,$findText)
{
if (checkDomain($domain_check,$server,$findText))
{
class Emp
{
public $domain = "";
public $availability = "";
}
$e = new Emp();
$e->domain = $domain_check;
$e->availability = "available";
echo json_encode($e);
}
else
{
class Emp
{
public $domain = "";
public $availability = "";
}
$e = new Emp();
$e->domain = $domain_check;
$e->availability = "TAKEN";
echo json_encode($e);
}
}
?>