標籤:ready stream ber 參數 session web服務 arch cookies tput
- display_errors
本條指令控制PHP是否輸出errors、notices、warnings。一般在開發模式下開啟,在產品模式下關閉。
有點坑的是,php.ini中,檔案開頭就又關於display_errors指令的介紹,但是,在後面才是設定。我第一次就是在開頭處設定了,但是在檔案後面因為還存在display_errors真正設定的地方,導致後面的設定覆蓋了前面的設定,從而使我的設定一直無法生效。坑!坑!坑!
在爬坑過程中用到的幾個方法:
1. ini_get()
2. php --ini 查看php載入的是哪個php.ini檔案
3. php-fpm -t 通過php-fpm 測試組態檔案指令查看php-fpm載入的php-fpm.conf檔案路徑
4. phpinfo()
另外的一個總結:php.ini的載入邏輯:
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable. (As of PHP 5.2.0)
; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)
; 4. Current working directory (except CLI)
; 5. The web server‘s directory (for SAPI modules), or directory of PHP
; (otherwise in Windows)
; 6. The directory from the --with-config-file-path compile time option, or the
; Windows directory (C:\windows or C:\winnt)
由上可知,php會
1. 首先從sapi的參數中查看是否指定了php.ini
2. 如果沒有就通過PHPRC環境變數指定的路徑尋找
3. 如果沒有,或者PHPRC環境變數未設定,則從registry keys註冊表從找(專用於windows)
4. 從當前的工作目錄中尋找(除了CLI)
5. 從web伺服器的目錄中尋找(對於SAPI模組),或者PHP的目錄中
6. 從php編譯時間指定的--with-config-file-path中尋找,或者在windows directory(C:\windows or C:\winnt)
- output_buffering
; Output buffering is a mechanism for controlling how much output data
; (excluding headers and cookies) PHP should keep internally before pushing that
; data to the client. If your application‘s output exceeds this setting, PHP
; will send that data in chunks of roughly the size you specify.
; Turning on this setting and managing its maximum buffer size can yield some
; interesting side-effects depending on your application and web server.
; You may be able to send headers and cookies after you‘ve already sent output
; through print or echo. You also may see performance benefits if your server is
; emitting less packets due to buffered output versus PHP streaming the output
; as it gets it. On production servers, 4096 bytes is a good setting for performance
; reasons.
; Note: Output buffering can also be controlled via Output Buffering Control functions.
由上可知,本條指令控制是否開啟輸出緩衝。
注意,當開啟輸出緩衝時,header()、session_start()等於response header有關的函數,可能可以在輸出之後調用。當關閉本指令時,因為回應標頭是向發出的,所以在這些函數之前,不能存在輸出。
- ?
php.ini設定相關資訊匯總