Ec (2); 1, ini_get: returnsthevalueofconfigurationoptionasastringonsuccess, oranemptystringonfailure (read php tutorial. ini configuration file value) 2,; WhethertoallowthetreatmentofURLs (likehttp: script ec (2); script
1, ini_get: Returns the value of the configuration option as a string on success, or an empty string on failure (read the value in the php tutorial. ini configuration file)
2,; Whether to allow the treatment of URLs (like http: // or ftp: //) as files.
Allow_url_fopen = On (content in the configuration file)
3. fopen ("rb"): If the 'B' flag is not specified when operating the binary file, some strange problems may occur, including corrupted image files and strange questions about rn characters.
Note: For portability, we strongly recommend that you always use the 'B' flag when opening a file with fopen.
NOTE: For the sake of portability, we strongly recommend that you rewrite the code dependent on the 'T' mode to use the correct line terminator and change it to the 'B' mode.
4, strtolower -- Make a string lowercase
5, curl_init (): curl_init -- Initialize a cURL session (Initialize a cUrl session)
/**
Obtain Remote File Content
@ Param $ url: the http address of the file
*/
Function fopen_url ($ url)
{
If (function_exists ('file _ get_contents ')){
$ File_content = @ file_get_contents ($ url );
} Elseif (ini_get ('Allow _ url_fopen') & ($ file = @ fopen ($ url, 'rb '))){
$ I = 0;
While (! Feof ($ file) & $ I ++ <1000 ){
$ File_content. = strtolower (fread ($ file, 4096 ));
}
Fclose ($ file );
} Elseif (function_exists ('curl _ init ')){
$ Curl_handle = curl_init ();
Curl_setopt ($ curl_handle, CURLOPT_URL, $ url );
Curl_setopt ($ curl_handle, CURLOPT_CONNECTTIMEOUT, 2 );
Curl_setopt ($ curl_handle, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ curl_handle, CURLOPT_FAILONERROR, 1 );
Curl_setopt ($ curl_handle, CURLOPT_USERAGENT, 'trackback Spam check'); // reference Spam Check
$ File_content = curl_exec ($ curl_handle );
Curl_close ($ curl_handle );
} Else {
$ File_content = '';
}
Return $ file_content;
}
?>