调试PHP程序的多种方法介绍
调试的定义:通过一定方法,在程序中找到并减少缺陷的数量,从而使其能正常工作。
这里说一些如何调试PHP程序的经验。
一、PHP自带的调试功能
1、自带的报错功能
两个名词:开发环境是开发人员在进行开发和调试的环境,生产环境是最终客户在用的线上环境;
开发环境和生产环境要分开设置报错功能。
(1)开发环境
开发环境需要打开报错,以下是php.ini的配置项及其说明:
;Thisdirectivesetstheerrorreportinglevel. ;DevelopmentValue:E_ALL|E_STRICT(Showallerrors,warningsandnoticesincludingcodingstandards.) error_reporting=E_ALL|E_STRICT
;ThisdirectivecontrolswhetherornotandwherePHPwilloutputerrors, ;noticesandwarningstoo.Erroroutputisveryusefulduringdevelopment. ;DevelopmentValue:On display_errors=On