这是我当前的代码:
function get_cmd ()
{
if (file_exists('/usr/local/bin/whois'))
$cmd = '/usr/local/bin/whois';
elseif (file_exists('/usr/bin/whois'))
$cmd = '/usr/bin/whois';
elseif (file_exists('/bin/whois'))
$cmd = '/bin/whois';
else
die('whois shell command does not exist');
return $cmd;
}
function get_whois ($cmd, $domain)
{
if (checkdnsrr($domain))
$result = shell_exec(escapeshellcmd($cmd ." ". $domain));
else
$result = 'DOMAIN IS NOT REGISTERED';
return $result;
}
$cmd = get_cmd();
echo get_whois($cmd, 'google.com');
现在,有没有一种不同的方法可以让我轻松提取域的到期日期,而不必想出一大堆不同的正则表达式?因为每个域的信息格式都会不同...