我有一个模式status: available
,但冒号符号不起作用。如何修改这个模式?
我在代码中弄乱了一些东西,当我找到它时会通知你。谢谢你
好的,我分解了代码。我正在为域可用性编写脚本。
<?php
$server = 'whois.cira.ca';
$pattern = 'status: available';
$domain = 'nonexistingdomain';
$extension = '.ca';
$buffer = NULL;
$sock = fsockopen($server, 43) or die('Error Connecting To Server: ' . $server);
fputs($sock, $domain.$extension . "\r\n");
while( !feof($sock) )
{
$buffer .= fgets($sock,128);
}
//If I give a value localy to $buffer (like below) it works, but if $buffer takes the value from fgets() function it wont
$buffer = "Domain name: nonexistingdomain.ca Domain status: available % WHOIS look-up made at 2013-01-16 12:35:45 (GMT) % % Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal % Notice, available at http://www.cira.ca/legal-notice/?lang=en % % (c) 2013 Canadian Internet Registration Authority, (http://www.cira.ca/) NO";
fclose($sock);
if(preg_match("/$pattern/", $buffer))
echo "YEP";
else
echo "NO";
?>
如果我将 $pattern 更改为“可用”,它会起作用!