SlideShare a Scribd company logo
PHP DEBUGGING
BEYOND ECHO
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)
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
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
Php debugging
SCRIPT LEVEL ERROR MANAGEMENT
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
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
TRIGGER_ERROR
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!

More Related Content

Similar to Php debugging (20)

PPTX
Error handling
Meherul1234
 
PDF
Java: Finding Bugs, Fixing Bugs in IBM Domino Designer and XPages
panagenda
 
PDF
Module-4_WTA_PHP Class & Error Handling
SIVAKUMAR V
 
PPT
Error reporting in php
Mudasir Syed
 
PPT
Computer languages
ABHINAV SINGH
 
PDF
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
PDF
Secure PHP Coding
Narudom Roongsiriwong, CISSP
 
PPTX
Php unit i
BagavathiLakshmi
 
PPT
Php Ppt
Hema Prasanth
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PDF
LESSON__1-15 C-PROGRAMMING.p algorithm df
AparnaPriyadarsiniMe
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPTX
Post-mortem Debugging of Windows Applications
GlobalLogic Ukraine
 
PPTX
PHP ITCS 323
Sleepy Head
 
PDF
Error Handling In PHP with all Try catch anf various runtime errors
PraveenHegde20
 
PPTX
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Sam Bowne
 
DOC
compiler vs interpreter
Faculty of Science , portsaid Univeristy
 
PDF
CNIT 126 4: A Crash Course in x86 Disassembly
Sam Bowne
 
PDF
Exception Handling: Designing Robust Software in Ruby
Wen-Tien Chang
 
PPT
Compilers and interpreters
RAJU KATHI
 
Error handling
Meherul1234
 
Java: Finding Bugs, Fixing Bugs in IBM Domino Designer and XPages
panagenda
 
Module-4_WTA_PHP Class & Error Handling
SIVAKUMAR V
 
Error reporting in php
Mudasir Syed
 
Computer languages
ABHINAV SINGH
 
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
Secure PHP Coding
Narudom Roongsiriwong, CISSP
 
Php unit i
BagavathiLakshmi
 
Php Ppt
Hema Prasanth
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
LESSON__1-15 C-PROGRAMMING.p algorithm df
AparnaPriyadarsiniMe
 
introduction to php and its uses in daily
vishal choudhary
 
Post-mortem Debugging of Windows Applications
GlobalLogic Ukraine
 
PHP ITCS 323
Sleepy Head
 
Error Handling In PHP with all Try catch anf various runtime errors
PraveenHegde20
 
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Sam Bowne
 
CNIT 126 4: A Crash Course in x86 Disassembly
Sam Bowne
 
Exception Handling: Designing Robust Software in Ruby
Wen-Tien Chang
 
Compilers and interpreters
RAJU KATHI
 

Recently uploaded (20)

PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Q2 Leading a Tableau User Group - Onboarding
lward7
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Q2 Leading a Tableau User Group - Onboarding
lward7
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Ad

Php debugging

  • 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. 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. 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
  • 6. SCRIPT LEVEL ERROR MANAGEMENT
  • 7. 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
  • 8. 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
  • 10. 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!

Editor's Notes

  • #4: 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)
  • #7: If there is a fatal error in the script, php.ini level error reporting supercedes the script
  • #10: E_USER_NOTICE – default for trigger_errorE_USER_WARNINGE_USER_ERROR – stops execution