關於php設定檔

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   使用   ar   strong   for   

一:設定檔(php.ini)在 PHP 啟動時被讀取。對於伺服器模組版本的 PHP,僅在 網頁伺服器啟動時讀取一次。對於 CGI 和 CLI 版本,每次調用都會讀取。

二:Note that the CLI version of PHP does not appear to take into account any php.ini configuration file. As such, something like a max_execution_time limit setting you may think is being applied is actually not being used, and instead defaulting to 0 (which is unlimited).

三:PHP 運行於 Apache 模組方式

當使用 PHP 作為 Apache 模組時,也可以用 Apache 的設定檔(例如 httpd.conf)和 .htaccess檔案中的指令來修改 PHP 的配置設定。需要有“AllowOverride Options”或“AllowOverride All”許可權才可以。

有幾個 Apache 指令可以使使用者在 Apache 設定檔內部修改 PHP 的配置。哪些指令屬於 PHP_INI_ALL , PHP_INI_PERDIR 或 PHP_INI_SYSTEM 中的哪一個,請參考附錄中的 php.ini 配置選項列表。

四:PHP 常量不存在於 PHP 之外。例如在 httpd.conf 中不能使用 PHP 常量如 E_ALL 或 E_NOTICE 來設定 error_reporting指令,因為其無意義,實際等於 0。應該用相應的掩碼值來替代。這些常量可以在 php.ini 中使用。

五:

<?php
// You can use isset or is_null for $_SERVER[‘FCGI_SERVER_VERSION‘]
function isFastCGI () {
return !is_null($_SERVER[‘FCGI_SERVER_VERSION‘]);
}
?>

六:在PHP 5之中,提供了一個新的錯誤層級 E_STRICT 。 因為 E_STRICT 並不包含在 E_ALL 之中,你必須明確啟用才能顯示這個類別的錯誤資訊。在開發階段啟用 E_STRICT 會有一些好處。嚴格的資訊將協助你使用最新和最好的建議的方法來編寫代碼,例如它會警告你使用了將被廢棄的函數。

 

七:儘管 display_errors 也可以在運行時設定 (使用 ini_set() ), 但是指令碼出現致命錯誤時任何運行時的設定都是無效的。 因為在這種情況下預期啟動並執行操作不會被執行。

display_startup_errors boolean

即使 display_errors 設定為開啟, PHP 啟動過程中的錯誤資訊也不會被顯示。強烈建議除了調試目的以外,將 display_startup_errors 設定為關閉。

例如:

error_reporting(E_ALL);
ini_set(‘display_errors‘,‘Off‘);
echo 234/0
exit;

這樣仍然會報錯:Parse error: syntax error, unexpected T_EXIT, expecting ‘,‘ or ‘;‘ 

 

關於php設定檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.