SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
PHP Arrays & Classes
Developed by
Mr.V.Sivakumar
PHP Arrays
• In general, an array is a data structure that allows the
programmer to collect a number of related elements
together in a single variable.
• Unlike most other programming languages, in PHP an
array is actually an ordered map, which associates each
value in the array with a key.
• PHP array is not only like other languages arrays, but it
is also like their vector, hash table, dictionary, and list
collections.
Multidimensional arrays
Multidimensional arrays
superglobal arrays
• PHP uses special predefined associative arrays called superglobal variables
that allow the programmer to easily access HTTP headers, query string
parameters.
• They are called superglobal because these arrays are always in scope and
always exist, ready for the programmer to access or modify them without
having to use the global keyword.
Errors and Exceptions
• A failure in any one of these systems will mean that the web application
will no longer run successfully.
• Types of errors
■ Expected errors
■ Warnings
■ Fatal errors
• An expected error is an error that routinely occurs during an application.
An error as a result of user inputs, for instance, entering letters when
numbers were expected.
• Users will leave fields blank, enter text when numbers were expected, type
in too much or too little text, forget to click certain things.
Errors and Exceptions
• Warnings, that generate a PHP warning message (which may or may
not be displayed) but will not halt the execution of the page. For
instance, calling a function without a required parameter will
generate a warning but not stop execution.
• Fatal errors, which are serious in that the execution of the page will
terminate unless handled in some way. These should truly be
exceptional and unexpected, such as a required input file being
missing or a database table or field disappearing.
PHP Error reporting
• There are three main error reporting flags:
■ error_reporting
■ display_errors
■ log_errors
• The error_reporting setting specifies which type of errors are to be
reported
error_reporting = E_ALL / E_ERROR / E_WARNING
• display_error setting specifies whether error messages should or
should not be displayed in the browser.
php.ini file: display_errors = Off
• log_error setting specifies whether error messages should or should
not be sent to the server error log log_errors = On
PHP Error and Exception handling
• Two mechanisms for handling runtime errors:
■ procedural error handling
■ Object-Oriented exception handling
• procedural approach to error handling, the programmer needs to
explicitly test for error conditions after performing a task that might
generate an error.
If(condition){ some code here } else { }
• When a runtime error occurs, PHP throws an exception. This
exception can be caught and handled either by the function, class, or
page that generated the exception or by the code that called the
function or class using
try{ condition} catch(Exception e) {}
PHP Error and Exception handling
• Custom error and exception handlers
• It should provide the developer with detailed information
about the state of the application when the exception
occurred, information about the exception, and when it
happened.
• It should hide any of those details from the regular end user,
and user with a generic message such as “Sorry but there was
a problem,” or “Sorry but the system is down for
maintenance.”
Function myException($Exception)
{ Our own exception message / Code here }
Source Reference: Randy Connolly, Ricardo Hoar, Fundamentals of Web Development, Pearson
Thank you

Contenu connexe

Tendances

Unit 1 - SAP System Architecture
Unit 1 - SAP System ArchitectureUnit 1 - SAP System Architecture
Unit 1 - SAP System Architecturedubon07
 
Error Correction Techniques
Error Correction TechniquesError Correction Techniques
Error Correction TechniquesKelly Bauer
 
C and its errors
C and its errorsC and its errors
C and its errorsJunaid Raja
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmmshoaib15
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streamsRubaNagarajan
 
Unit 3 - Transparent tables in the ABAP Dictionary
Unit 3 - Transparent tables in the ABAP DictionaryUnit 3 - Transparent tables in the ABAP Dictionary
Unit 3 - Transparent tables in the ABAP Dictionarydubon07
 
Applet & graphics programming
Applet & graphics programmingApplet & graphics programming
Applet & graphics programmingShekh Ahmed
 
EclipseCon 2015 - Generating business applications from executable models
EclipseCon 2015 - Generating business applications from executable modelsEclipseCon 2015 - Generating business applications from executable models
EclipseCon 2015 - Generating business applications from executable modelsRafael Chaves
 
Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)Sam Bowne
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with pythonroskakori
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingPVS-Studio
 
Types of errors
Types of errorsTypes of errors
Types of errorsRiya Josh
 
VivaMP, system of detecting errors in the code of parallel C++ programs using...
VivaMP, system of detecting errors in the code of parallel C++ programs using...VivaMP, system of detecting errors in the code of parallel C++ programs using...
VivaMP, system of detecting errors in the code of parallel C++ programs using...PVS-Studio
 

Tendances (19)

Unit 1 - SAP System Architecture
Unit 1 - SAP System ArchitectureUnit 1 - SAP System Architecture
Unit 1 - SAP System Architecture
 
Error Correction Techniques
Error Correction TechniquesError Correction Techniques
Error Correction Techniques
 
Pl sql
Pl sqlPl sql
Pl sql
 
C and its errors
C and its errorsC and its errors
C and its errors
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
 
Unit 3 - Transparent tables in the ABAP Dictionary
Unit 3 - Transparent tables in the ABAP DictionaryUnit 3 - Transparent tables in the ABAP Dictionary
Unit 3 - Transparent tables in the ABAP Dictionary
 
Applet & graphics programming
Applet & graphics programmingApplet & graphics programming
Applet & graphics programming
 
EclipseCon 2015 - Generating business applications from executable models
EclipseCon 2015 - Generating business applications from executable modelsEclipseCon 2015 - Generating business applications from executable models
EclipseCon 2015 - Generating business applications from executable models
 
Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with python
 
PHP 5
PHP 5PHP 5
PHP 5
 
FileMaker BaseElements Tool
FileMaker BaseElements ToolFileMaker BaseElements Tool
FileMaker BaseElements Tool
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code logging
 
Session 06 - Java Basics
Session 06 - Java BasicsSession 06 - Java Basics
Session 06 - Java Basics
 
Types of errors
Types of errorsTypes of errors
Types of errors
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
 
VivaMP, system of detecting errors in the code of parallel C++ programs using...
VivaMP, system of detecting errors in the code of parallel C++ programs using...VivaMP, system of detecting errors in the code of parallel C++ programs using...
VivaMP, system of detecting errors in the code of parallel C++ programs using...
 
Ppt lesson 06
Ppt lesson 06Ppt lesson 06
Ppt lesson 06
 

Similaire à PHP Arrays, Classes, Errors & Exceptions

Similaire à PHP Arrays, Classes, Errors & Exceptions (20)

Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
php basic part one
php basic part onephp basic part one
php basic part one
 
1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master1336333055 php tutorial_from_beginner_to_master
1336333055 php tutorial_from_beginner_to_master
 
Php1
Php1Php1
Php1
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
 
Php intro
Php introPhp intro
Php intro
 
Php1
Php1Php1
Php1
 
Php1
Php1Php1
Php1
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 

Dernier

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 

Dernier (20)

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 

PHP Arrays, Classes, Errors & Exceptions

  • 1. PHP Arrays & Classes Developed by Mr.V.Sivakumar
  • 2. PHP Arrays • In general, an array is a data structure that allows the programmer to collect a number of related elements together in a single variable. • Unlike most other programming languages, in PHP an array is actually an ordered map, which associates each value in the array with a key. • PHP array is not only like other languages arrays, but it is also like their vector, hash table, dictionary, and list collections.
  • 3.
  • 4.
  • 7. superglobal arrays • PHP uses special predefined associative arrays called superglobal variables that allow the programmer to easily access HTTP headers, query string parameters. • They are called superglobal because these arrays are always in scope and always exist, ready for the programmer to access or modify them without having to use the global keyword.
  • 8.
  • 9. Errors and Exceptions • A failure in any one of these systems will mean that the web application will no longer run successfully. • Types of errors ■ Expected errors ■ Warnings ■ Fatal errors • An expected error is an error that routinely occurs during an application. An error as a result of user inputs, for instance, entering letters when numbers were expected. • Users will leave fields blank, enter text when numbers were expected, type in too much or too little text, forget to click certain things.
  • 10. Errors and Exceptions • Warnings, that generate a PHP warning message (which may or may not be displayed) but will not halt the execution of the page. For instance, calling a function without a required parameter will generate a warning but not stop execution. • Fatal errors, which are serious in that the execution of the page will terminate unless handled in some way. These should truly be exceptional and unexpected, such as a required input file being missing or a database table or field disappearing.
  • 11. PHP Error reporting • There are three main error reporting flags: ■ error_reporting ■ display_errors ■ log_errors • The error_reporting setting specifies which type of errors are to be reported error_reporting = E_ALL / E_ERROR / E_WARNING • display_error setting specifies whether error messages should or should not be displayed in the browser. php.ini file: display_errors = Off • log_error setting specifies whether error messages should or should not be sent to the server error log log_errors = On
  • 12. PHP Error and Exception handling • Two mechanisms for handling runtime errors: ■ procedural error handling ■ Object-Oriented exception handling • procedural approach to error handling, the programmer needs to explicitly test for error conditions after performing a task that might generate an error. If(condition){ some code here } else { } • When a runtime error occurs, PHP throws an exception. This exception can be caught and handled either by the function, class, or page that generated the exception or by the code that called the function or class using try{ condition} catch(Exception e) {}
  • 13. PHP Error and Exception handling • Custom error and exception handlers • It should provide the developer with detailed information about the state of the application when the exception occurred, information about the exception, and when it happened. • It should hide any of those details from the regular end user, and user with a generic message such as “Sorry but there was a problem,” or “Sorry but the system is down for maintenance.” Function myException($Exception) { Our own exception message / Code here }
  • 14. Source Reference: Randy Connolly, Ricardo Hoar, Fundamentals of Web Development, Pearson Thank you