PHP can detect websites in batches. php can detect websites in batches.
This example describes how PHP can check whether a website can be opened normally in batches. We will share this with you for your reference. The details are as follows:
The curl_setopt function is an important function in php. It can imitate some user behaviors, such as user logon and registration.
<? Php // sets the maximum execution time to 120 seconds. ini_set ('max _ execution_time ', 120); function httpcode ($ url) {$ ch = curl_init (); $ timeout = 3; curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ ch, latency, 1); curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_exec ($ ch); return $ httpcode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); curl_c Lose ($ ch) ;}$ check_web = array ('HTTP: // future,); for ($ I = 0; $ I <count ($ check_web ); $ I ++) {echo $ check_web [$ I]. '-> '. httpcode ($ check_web [$ I]). '<br>' ;}?>
Usage:
If it is displayed as 200, it is normal. If it is displayed with other values, it means it is abnormal. 3 after $ timeout is the set timeout seconds.
As follows: