debugging - How to get useful error messages in PHP? -


i find programming in php quite frustrating. quite try , run script , blank screen back. no error message, empty screen. cause might have been simple syntax error (wrong bracket, missing semicolon), or failed function call, or else entirely.

it difficult figure out went wrong. end commenting out code, entering "echo" statements everywhere, etc. trying narrow down problem. there surely must better way, right?.

so, there way php produce useful error message java does? can recommend php debugging tips, tools , techniques?

for syntax errors, need enable error display in php.ini. default these turned off because don't want "customer" seeing error messages. check page in php documentation information on 2 directives: error_reporting , display_errors. display_errors 1 want change. if can't modify php.ini, can add following lines .htaccess file:

php_flag  display_errors        on php_value error_reporting       2039 

you may want consider using value of e_all (as mentioned gumbo) version of php error_reporting of errors. more info

3 other items: (1) can check error log file have of errors (unless logging has been disabled). (2) adding following 2 lines debug errors not syntax errors:

error_reporting(-1); ini_set('display_errors', 'on'); 

(3) option use editor checks errors when type, such phped. phped comes debugger can provide more detailed information. (the phped debugger similar xdebug , integrates directly editor use 1 program everything.)

cartman's link good: http://www.ibm.com/developerworks/library/os-debug/


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -