PHP 新手在初期搭建完開發(fā)環(huán)境后,開發(fā)時(shí)出現(xiàn)語(yǔ)法錯(cuò)誤時(shí),服務(wù)器返回500 ( 服務(wù)器內(nèi)部錯(cuò)誤),而不是返回錯(cuò)誤提示。 這時(shí)候需要對(duì)開發(fā)環(huán)境做一些配置,幫助你快速查找問(wèn)題原因,定位問(wèn)題,解決問(wèn)題。
找到 php的配置文件 /etc/php.ini
配置參數(shù)值:
display_errors = On error_reporting = E_ALL | E_STRICT
重啟apache 服務(wù)
service httpd restart
這個(gè)時(shí)候 瀏覽器已經(jīng)可以輸出錯(cuò)誤信息了。
需要再配置下 apache /etc/httpd/conf/httpd.conf
在 apache的配置文件最后添加 兩行:
php_flag display_errors on php_value error_reporting 2039
重啟apache。
對(duì)php.ini 中參數(shù)的設(shè)置 也可用在php代碼中完成。
調(diào)用:調(diào)用ini_set()函數(shù)
//開啟php.ini中的display_errors指令 ini_set('display_errors',1); //通過(guò)error_reporting()函數(shù)設(shè)置,輸出所有級(jí)別的錯(cuò)誤報(bào)告 error_reporting(E_ALL);
相關(guān)參考:php中文網(wǎng)