PHP 動態配置運行時環境參數ini_xxx,extension_loaded

來源:互聯網
上載者:User

標籤:io   ar   java   sp   on   bs   ad   new   as   

php中的配置項如果在php.ini中的是靜態配置項,伺服器啟動時唯讀取一次,因此,運行時修改起不了作用,一般修改後需要重啟。

摘要說了,由於一些限制,我們無法完成動態配置,因此需要進行動態配置,注意,這種方式不會改變php.ini,放心去試一下吧

string ini_set ( string $varname , string $newvalue )string ini_get ( string $varname )array ini_get_all ([ string $extension [, bool $details = true ]] ) //讀取所有配置項void ini_restore ( string $varname ) //回複所有配置項bool extension_loaded ( string $name )bool dl ( string $library )

如下面的設定

<?phpecho ini_get(‘display_errors‘); //設定是不是允許顯示錯誤,//在發布的產品中禁止設定為true,一面造成安全隱患,這裡類似在“真機”調試,所以開啟if (!ini_get(‘display_errors‘)) {    ini_set(‘display_errors‘, ‘1‘);}echo ini_get(‘display_errors‘);?>

再如

<?phpif (!extension_loaded(‘gd‘)) {    if (!dl(‘gd.so‘)) {        exit;    }}?>


PHP 動態配置運行時環境參數ini_xxx,extension_loaded

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.