PHP 的 require & include
發表於 | 8.28.2009 | 無回應
require() is identical to include() except upon failure it will produce a fatal E_ERROR level error.
In other words, it will halt the script whereas include() only emits a warning (E_WARNING)...
也就是說, 相對 include() 而言, require() 一旦有誤時, 程式會終止執行
which allows the script to continue.
而 include() 除了警語, 程式還是會跑完
#require() 的用法和 include() 一樣
#都是賦予一個檔案, 所以錯誤都是出現在找不到檔案
include "/path/to/file";
#這樣的寫法較標準, 雖然 include ("/path/to/file"); 也可以
#在迴圈內需要 include "/path/to/file"; 時
#而該 file 內如果定義有 user function 的話
#應該將 user function 移到迴圈外再引用
#或者另外將 user function 以檔案的方式在迴圈開始前 include()
#否則會在迴圈內重複宣告同樣一個 user function
Fatal error: Cannot redeclare user_function() (previously declared)
#這個 user_function 在迴圈內只會在第一次 include() 時使用, 然後因錯誤而終止執行
cygrunsrv 和 services.msc
發表於 | 7.25.2009 | 無回應
cygrunsrv --help 後可知
Main options: Exactly one is required. (其一)
-I, --install <svc_name>; Installes a new service named .
-R, --remove <svc_name>; Removes a service named .
-S, --start <svc_name>; Starts a service named .
-E, --stop <svc_name>; Stops a service named .
-Q, --query <svc_name>; Queries a service named .
-L, --list [server]; Lists services that have been installed with cygrunsrv.
<svc_name> can be a local service or "server/svc_name" or "server\svc_name".
Required install options: (必須)
-p, --path <app_path>; Application path which is run as a service.
假設 -I 的 svc_name 是 service_name
便可在 Windows 下執行 services.msc 後的名稱欄位找到
而 cygrunsrv 還有以下參數
Miscellaneous install options: (選用)也就是說, -d 之後的名稱 (display name) 會顯示在 services.msc 的名稱欄位, 但實際的服務名稱不變
-d, --disp <display name>; Optional string which contains the display name of the service.
-f, --desc <description>; Optional string which contains the service description.
如果沒有 -d, 其預設值就是 -I 的 service_name (defaults to service name.)
而 -f 所給的字串就是 services.msc 的描述欄位
換句話說, Windows 下開啟 regedit.exe
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\]
查詢新增的服務名稱時, 無論有無下 -d 的參數, 應該查找 -I 的 service_name
WordPress 2.7+ under LightTPD
LightTPD 跑 WordPress 時出現的錯誤 (error.log)
(request.c.1115) POST-request, but content-length missing -> 411
主要是得明確定義 Content-Length 為 0 for a null body (is_null($r['body']))
即在 /wordpress/wp-includes/http.php 中, 第 245 行
加入 {{{$r['headers']['Content-Length'] = 0;}}}
如下所示
if ( is_null($r['body']) ) {
{{{$r['headers']['Content-Length'] = 0;}}}#第 245 行
$transports = WP_Http::_getTransport($r);
}