1,ini_get : Returns the value of the configuration option as a string on success, or an empty string on failure(讀取 php教程.ini 設定檔中的值)
2,; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On(設定檔中的內容)
3,fopen( "rb"): 在操作二進位檔案時如果沒有指定 'b' 標記,可能會碰到一些奇怪的問題,包括壞掉的圖片檔案以及關於 rn 字元的奇怪問題。
注意: 為移植性考慮,強烈建議在用 fopen() 開啟檔案時總是使用 'b' 標記。
注意: 再一次,為移植性考慮,強烈建議你重寫那些依賴於 't' 模式的代碼使其使用正確的行結束符並改成 'b' 模式。
4,strtolower -- Make a string lowercase
5,curl_init() :curl_init -- Initialize a cURL session(初始化一個cUrl會話)
<?
/**
擷取遠程檔案內容
@param $url 檔案http地址
*/
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'); //引用垃圾郵件檢查
$file_content = curl_exec($curl_handle);
curl_close($curl_handle);
} else {
$file_content = '';
}
return $file_content;
}
?>