Php code used to check whether a geographic IP address is available
Source: Internet
Author: User
Php code used to check whether a geographic IP address is available. For more information, see
The code is as follows:
/*************************************** *****
*
* Function name: curl_string ($ url, $ proxy)
* For use: check the proxy IP address
* Author: Li feilin
* Date: 2011-11-09
*
**************************************** ****/
Function curl_string ($ url, $ proxy)
{
$ User_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv: 1.9.0.5) Gecko/2008120122 Firefox/3.0.5 FirePHP/0.2.1 ";
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_PROXY, $ proxy );
Curl_setopt ($ ch, CURLOPT_URL, $ url); // you can specify the IP address to be accessed.
Curl_setopt ($ ch, CURLOPT_USERAGENT, $ user_agent); // simulate the browser used by the user
@ Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); // use automatic redirect
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 120); // Set the timeout value.
Curl_setopt ($ ch, CURLOPT_AUTOREFERER, 1); // automatically sets Referer
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.