1
爲什麼不能使用preg_match
php和fsockopen
響應數據?爲什麼不能將preg_match php與fsockopen響應數據一起使用?
我試圖使用preg_match
與$response
獲得過期日期。
但不行,我該怎麼辦?
<?PHP
$server = "whois.verisign-grs.com";
$domain_check = "stackoverflow.com";
$con = fsockopen($server, 43);
if (!$con) return false;
fputs($con, $domain_check."\r\n");
$response = ' :';
while(!feof($con))
{
$response .= fgets($con,128);
}
// echo $response;
preg_match('/Expiration Date: (.+?) >>> Last update of whois database/',$response,$expires_date_month_year);
$expires_date_month_year_val = $expires_date_month_year[1];
echo $expires_date_month_year_val;
?>
注:
當我回聲$response
它會看起來像
: Whois Server Version 2.0 Domain names in the .com and .net domains can now be registered with many different competing registrars. Go to http://www.internic.net for detailed information. Domain Name: STACKOVERFLOW.COM Registrar: NAME.COM, INC. Sponsoring Registrar IANA ID: 625 Whois Server: whois.name.com Referral URL: http://www.name.com Name Server: CF-DNS01.STACKOVERFLOW.COM Name Server: CF-DNS02.STACKOVERFLOW.COM Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Updated Date: 26-nov-2015 Creation Date: 26-dec-2003 Expiration Date: 26-dec-2016 >>> Last update of whois database: Fri, 22 Apr 2016 15:30:45 GMT <<< For more information on Whois status codes, please visit https://icann.org/epp NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar. Users may consult the sponsoring registrar's Whois database to view the registrar's reported date of expiration for this registration. TERMS OF USE: You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated except as reasonably necessary to register domain names or modify existing registrations; the Data in VeriSign Global Registry Services' ("VeriSign") Whois database is provided by VeriSign for information purposes only, and to assist persons in obtaining information about or related to a domain name registration record. VeriSign does not guarantee its accuracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to VeriSign (or its computer systems). The compilation, repackaging, dissemination or other use of this Data is expressly prohibited without the prior written consent of VeriSign. You agree not to use electronic processes that are automated and high-volume to access or query the Whois database except as reasonably necessary to register domain names or modify existing registrations. VeriSign reserves the right to restrict your access to the Whois database in its sole discretion to ensure operational stability. VeriSign may restrict or terminate your access to the Whois database for failure to abide by these terms of use. VeriSign reserves the right to modify these terms at any time. The Registry database contains ONLY .COM, .NET, .EDU domains and Registrars.
你檢查什麼價值'$ response'實際上是試圖用'preg_match'在它之前? –
您已註釋的行('echo $ response');這顯示你什麼? –
我已更新問。 –