網頁

搜尋此網誌

2010年11月6日 星期六

PHP Client URL Library 用戶端程式庫

今天介紹PHP的Client URL Library,簡稱cURL,我們利用cURL將可以使被動處理的伺服器應用程式具有主動請求的程式。

cURL提供我們和其他伺服器通訊的功能(當作一個Client端),支援的通訊協定有HTTP、HTTPS、FTP、Gopher、Telnet、DICT、file與LDAP通訊協定,詳細的說明請參考PHP網站文件,位於PHP ManualFunction ReferenceOther Services之中。

主要是因為小黑學弟最近架設了新的網站,在 php.ini設定檔中開啟cURL功能,明明就是一個很簡單的設定,可是怎麼設定都發生錯誤,錯誤訊息是:

PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_curl.dll' - \xa7\xe4\xa4\xa3\xa8\xec\xab\xfc\xa9w\xaa\xba\xbc\xd2\xb2\xd5\xa1C\r\n in Unknown on line 0
[Sat Nov 06 00:00:00 2010] [notice] Apache/2.2.16 (Win32) PHP/5.2.14 configured -- resuming normal operations
[Sat Nov 06 00:00:00 2010] [notice] Server built: Jul 30 2010 16:15:37
[Sat Nov 06 00:00:00 2010] [notice] Parent: Created child process 7520
PHP Warning: PHP Startup: Unable to load dynamic library c:\\php\\'ext\\php_curl.dll' - \xa7\xe4\xa4\xa3\xa8\xec\xab\xfc\xa9w\xaa\xba\xbc\xd2\xb2\xd5\xa1C\r\n in Unknown on line 0
[Sat Nov 06 00:00:01 2010] [notice] Child 7520: Child process is running
[Sat Nov 06 00:00:01 2010] [notice] Child 7520: Acquired the start mutex.
[Sat Nov 06 00:00:01 2010] [notice] Child 7520: Starting 64 worker threads.
[Sat Nov 06 00:00:01 2010] [notice] Child 7520: Starting thread to listen on port 80.

經過十多個小時的努力debug查明原因,「無法載入動態程式庫php_curl.dll」就是因為PHP版本,PHP 5.2.14版本不知道是什麼原因造成php_curl.dll錯誤。經過實地測試 5.2.6至5.2.13版的PHP,這些版本都能夠成功使用cURL功能。

經過這次的經驗,我們必須記住一件事:軟體版本的更新雖然存在著「向下相容」與「修正錯誤」的原則,但是永遠不代表既有功能不會發生問題。當時遇到這個cURL問題一直以為是設定錯誤,直到最後才發現是版本問題...

難道這就是「墨菲定律(Murphy's law):凡是可能出錯的事均會出錯。」

###

沒有留言:

張貼留言

熱門文章