Php checks whether remote articles have program code. Today's whimsy, when I wrote a case for a customer, there was a place where users were asked to enter a url. however, to save the case, it was correct and accessible, although the customer did not ask for it, we still think of such a strange idea today. when I wrote a case for a customer, there was a place where the user was asked to fill in the url. However, the storage is correct and accessible. although the customer does not require it, we still want to do so by reading the remote article content using file_get_contents and ob_get_contents () of php, if there is one, it will be false. Here are the two instances I mentioned. for information about ob_get_contents (), we will go to php. in ini, modify the prefix of curl.
$ Url = 'http: // www.111cn.cn ';
If (@ file_get_contents ($ url )){
Echo 'ture ';
} Else {
Echo 'false ';
}
If (getcontent ($ url )){
Echo 'OB _ ture ';
} Else {
Echo 'OB _ false ';
}
Function getcontent ($ url ){
$ Ch = curl_init ($ url );
Ob_start ();
Curl_exec ($ ch );
$ Retmsg = ob_get_contents ();
Ob_clean ();
Ob_end_flush ();
Curl_close ($ ch );
Return $ retmsg;
}
?>
Declaration: for original articles on this site, please refer to www.111cn.cn/phper/php.html
Sorry, when I write a case to a customer, there is a place where users are required to fill in the url, but it is correct and accessible to save it, although the customer didn't ask for it, we still thought of this...