Your SlideShare is downloading. ×
0
PHP DEBUGGING
BEYOND ECHO
PHP MESSAGE TYPES
• Notice – not a best coding practice
• Warning – will probably cause errors upon execution
• Error – fa...
COMMON PHP ERROR LEVELS
Referenced by constants representing bit level integers to the interpreter
• E_ERROR – fatal run-t...
DISPLAYING ERRORS
• error_reporting – sets level via constant
• Default: all except E_NOTICE
• display_errors – displays e...
SCRIPT LEVEL ERROR MANAGEMENT
LOGGING ERRORS
• log_errors – toggle error logging
• Default: off
• log_errors_max_len – length of error message in bytes
...
DISPLAYING ERRORS
• error_reporting – sets level via constant
• Default: all except E_NOTICE
• display_errors – displays e...
TRIGGER_ERROR
DEBUG_BACKTRACE
• backtrace – sequence of function/method calls
• invaluable in debugging frameworks/complex structures
• ...
Php debugging
Upcoming SlideShare
Loading in...5
×

Php debugging

3,006

Published on

An overview of basic fundamental php debugging concepts meant to be accompanied by real world examples on a live or local web server

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,006
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • E_ERROR – out of memory is a common oneE_NOTICE – something is probably wrong; accessing a variable that is undefined or an undefined array index – useisset() for good logicE_STRICT – old or sloppy coding, reinforces forward compatibility – e.g., mixing scopes – statically calling a non-static method.E_DEPRECATED – split() function and creating objects by reference (not needed in PHP 5)
  • If there is a fatal error in the script, php.ini level error reporting supercedes the script
  • E_USER_NOTICE – default for trigger_errorE_USER_WARNINGE_USER_ERROR – stops execution
  • Transcript of "Php debugging"

    1. 1. PHP DEBUGGING BEYOND ECHO
    2. 2. PHP MESSAGE TYPES • Notice – not a best coding practice • Warning – will probably cause errors upon execution • Error – fatal (crash) • Occur when script is interpreted (no execution - e.g., “The white screen of death”), or at script execution (run-time error halts execution)
    3. 3. COMMON PHP ERROR LEVELS Referenced by constants representing bit level integers to the interpreter • E_ERROR – fatal run-time error (crash) • E_WARNING – run-time warning • E_NOTICE – run-time notice • E_STRICT – interpretation-time notice • E_DEPRECATED – run-time – will not work in future PHP versions • E_ALL – all notices, warnings, and errors
    4. 4. DISPLAYING ERRORS • error_reporting – sets level via constant • Default: all except E_NOTICE • display_errors – displays error to users (only use in development environment) • 1 or 0 – default is 1
    5. 5. SCRIPT LEVEL ERROR MANAGEMENT
    6. 6. LOGGING ERRORS • log_errors – toggle error logging • Default: off • log_errors_max_len – length of error message in bytes • default: 1024 • 0 is unlimited • error_log – full path to log file • default: NULL (goes to server error log; not a best practice) • set log file path outside of the web root
    7. 7. DISPLAYING ERRORS • error_reporting – sets level via constant • Default: all except E_NOTICE • display_errors – displays error to users (only use in development environment) • 1 or 0 – default is 1
    8. 8. TRIGGER_ERROR
    9. 9. DEBUG_BACKTRACE • backtrace – sequence of function/method calls • invaluable in debugging frameworks/complex structures • returns associative array – keyed in ascending order • lowest number - last execution • each contains function/method, line number, file, class, object, and arguments!
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×