問(wèn)題描述
我目前在 php 5.4 上運(yùn)行一個(gè)站點(diǎn),在此之前我在 5.3.8 上運(yùn)行我的站點(diǎn).不幸的是,php 5.4 結(jié)合了 E_ALL
和 E_STRICT
,這意味著我之前對(duì) error_reporting
的設(shè)置現(xiàn)在不起作用.我以前的值是 E_ALL &~E_NOTICE &~E_STRICT
我應(yīng)該一次只啟用一個(gè)值嗎?
I'm currently running a site on php 5.4, prior to this I was running my site on 5.3.8. Unfortunately, php 5.4 combines E_ALL
and E_STRICT
, which means that my previous setting for error_reporting
does not work now. My previous value was E_ALL & ~E_NOTICE & ~E_STRICT
Should I just enable values one at a time?
我有太多錯(cuò)誤,而且文件包含太多代碼需要我修復(fù).
I have far too many errors and the files contain too much code for me to fix.
推薦答案
正如評(píng)論者所說(shuō),最佳選項(xiàng)是修復(fù)錯(cuò)誤,但在時(shí)間或知識(shí)有限的情況下,這并不總是可行的.在您的 php.ini 更改
As the commenters have stated the best option is to fix the errors, but with limited time or knowledge, that's not always possible. In your php.ini change
error_reporting = E_ALL
到
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
如果您無(wú)權(quán)訪問(wèn) php.ini,您可以將其放入您的 .htaccess 文件中:
If you don't have access to the php.ini, you can potentially put this in your .htaccess file:
php_value error_reporting 30711
這是 E_ALL 值 (32767) 以及刪除 E_STRICT (2048) 和 E_NOTICE (8) 值.
This is the E_ALL value (32767) and the removing the E_STRICT (2048) and E_NOTICE (8) values.
如果您無(wú)權(quán)訪問(wèn) .htaccess 文件或它未啟用,您可能需要將它放在從瀏覽器調(diào)用加載的任何腳本的 PHP 部分的頂部:
If you don't have access to the .htaccess file or it's not enabled, you'll probably need to put this at the top of the PHP section of any script that gets loaded from a browser call:
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
其中之一應(yīng)該可以幫助您使用該軟件.通知和嚴(yán)格的內(nèi)容是問(wèn)題或潛在問(wèn)題的指標(biāo),您可能會(huì)發(fā)現(xiàn)某些代碼在 PHP 5.4 中無(wú)法正常工作.
One of those should help you be able to use the software. The notices and strict stuff are indicators of problems or potential problems though and you may find some of the code is not working correctly in PHP 5.4.
這篇關(guān)于在 PHP 5.4 中禁用嚴(yán)格標(biāo)準(zhǔn)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!