php如何输出错误信息

网站有问题,调试的是,显示错误信息是非常重要的。通过修改配置文件php.ini display_errors = On 开启错误显示即可。

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; For production environments, we recommend logging errors rather than
; sending them to STDOUT.
; Possible Values:
; Off = Do not display any errors
; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors

虽然可以通过 ini_set("display_errors", “On”) 进行设置,但是不是每次都有效的。只有程序可以运行的才行。