SlideShare una empresa de Scribd logo
1 de 12
Errors
Fatal Errors
Calling undefined functions
require() when the file does not exist
Fatal Errors - example
<?php
//call a non-existent function
test_function();
?>
Output
Fatal error: Call to undefined function test_function() in
/var/www/website/html/index.php on line 4
Warnings and Notices
Undefined variables
Referencing non-existent array keys
Typos
Wrong variable types passed to functions
Warnings and Notices -
Example
<?php
//initialise the string variable
$string = ‘a string’;
//explode() a string
explode($string); ?>
Output:
Warning: Wrong parameter count for explode() in
/var/www/website.com/html/index.php on line 6
Database Errors
Can’t connect to a database
Can’t access a table
Broken query
Fatal Errors
Usually displays a blank page
Error messages are hidden from users, but
are logged
Warnings and Notices
Page will display, but may stop executing
prematurely
Error messages are hidden from the user,
but are logged
Affects performance & user experience
Database Errors
If the database can’t connect, it returns a
fatal error
If a table/field can’t or found, or a query can’t
be executed, it returns a warning
Better Error Handling
Define a custom error handler:
set_error_handler(‘function_name’);
Accept five arguments:-
• error type
• message
• file name
• line number
• context
Better Error Handling -
continued
Do whatever you want to within the function
– Output a message to the user
– Send an email to someone dependent on the
error
Errors are still logged
Should be built into base systems
Does not work for a fatal error.
Better Error Handling -
continued
register_shutdown_function()
This function will be called once a fatal error
has happened
However, it is executed after PHP has
finished processing every single script
Be careful with it!

Más contenido relacionado

Similar a Errors

Php Error Handling
Php Error HandlingPhp Error Handling
Php Error Handling
mussawir20
 
Pourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMSPourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMS
Thomas Gasc
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
Michelangelo van Dam
 

Similar a Errors (20)

Php exceptions
Php exceptionsPhp exceptions
Php exceptions
 
PHP - Introduction to PHP Error Handling
PHP -  Introduction to PHP Error HandlingPHP -  Introduction to PHP Error Handling
PHP - Introduction to PHP Error Handling
 
Php Error Handling
Php Error HandlingPhp Error Handling
Php Error Handling
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Php manish
Php manishPhp manish
Php manish
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
CLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementCLR Exception Handing And Memory Management
CLR Exception Handing And Memory Management
 
Debugging With Php
Debugging With PhpDebugging With Php
Debugging With Php
 
Pourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMSPourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMS
 
Wikilims Road4
Wikilims Road4Wikilims Road4
Wikilims Road4
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Bioinformatica 27-10-2011-p4-files
Bioinformatica 27-10-2011-p4-filesBioinformatica 27-10-2011-p4-files
Bioinformatica 27-10-2011-p4-files
 
Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
 
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult CasesPositive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
 
PHP 5
PHP 5PHP 5
PHP 5
 
PHP Without PHP—Confoo
PHP Without PHP—ConfooPHP Without PHP—Confoo
PHP Without PHP—Confoo
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 

Último

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

Errors

  • 2. Fatal Errors Calling undefined functions require() when the file does not exist
  • 3. Fatal Errors - example <?php //call a non-existent function test_function(); ?> Output Fatal error: Call to undefined function test_function() in /var/www/website/html/index.php on line 4
  • 4. Warnings and Notices Undefined variables Referencing non-existent array keys Typos Wrong variable types passed to functions
  • 5. Warnings and Notices - Example <?php //initialise the string variable $string = ‘a string’; //explode() a string explode($string); ?> Output: Warning: Wrong parameter count for explode() in /var/www/website.com/html/index.php on line 6
  • 6. Database Errors Can’t connect to a database Can’t access a table Broken query
  • 7. Fatal Errors Usually displays a blank page Error messages are hidden from users, but are logged
  • 8. Warnings and Notices Page will display, but may stop executing prematurely Error messages are hidden from the user, but are logged Affects performance & user experience
  • 9. Database Errors If the database can’t connect, it returns a fatal error If a table/field can’t or found, or a query can’t be executed, it returns a warning
  • 10. Better Error Handling Define a custom error handler: set_error_handler(‘function_name’); Accept five arguments:- • error type • message • file name • line number • context
  • 11. Better Error Handling - continued Do whatever you want to within the function – Output a message to the user – Send an email to someone dependent on the error Errors are still logged Should be built into base systems Does not work for a fatal error.
  • 12. Better Error Handling - continued register_shutdown_function() This function will be called once a fatal error has happened However, it is executed after PHP has finished processing every single script Be careful with it!