[PHP]如何解決curl_setopt_array於php4下執行
發表於 : 2010年 6月 9日, 12:11
curl_setopt_array() 這個 CURL 函數是在 php 5.1.3 之後才能支援的, 參考: http://www.im.tv/event/ie8/
若是在 php4 下或 php5.1.3之前的版本要如何執行呢? 上面的網址有解決方案, 如下:
就是判斷 curl_setopt_array 是否存在, 若不存在則定義 curl_setopt_array 為自己實作的仿 curl_setopt_array 功能即可!
若是在 php4 下或 php5.1.3之前的版本要如何執行呢? 上面的網址有解決方案, 如下:
代碼: 選擇全部
<?php
if (!function_exists('curl_setopt_array')) {
function curl_setopt_array(&$ch, $curl_options)
{
foreach ($curl_options as $option => $value) {
if (!curl_setopt($ch, $option, $value)) {
return false;
}
}
return true;
}
}
?>