SlideShare a Scribd company logo
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.
Module-4_WTA_PHP Class & Error Handling
Module-4_WTA_PHP Class & Error Handling
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.
Module-4_WTA_PHP Class & Error Handling
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
Ad

More Related Content

What's hot (19)

Unit 1 - SAP System Architecture
Unit 1 - SAP System ArchitectureUnit 1 - SAP System Architecture
Unit 1 - SAP System Architecture
dubon07
 
Error Correction Techniques
Error Correction TechniquesError Correction Techniques
Error Correction Techniques
Kelly Bauer
 
Pl sql
Pl sqlPl sql
Pl sql
Hitesh Kumar Markam
 
C and its errors
C and its errorsC and its errors
C and its errors
Junaid Raja
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
mshoaib15
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
RubaNagarajan
 
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
dubon07
 
Applet & graphics programming
Applet & graphics programmingApplet & graphics programming
Applet & graphics programming
Shekh 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 models
Rafael 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 python
roskakori
 
PHP 5
PHP 5PHP 5
PHP 5
Rafael Corral
 
FileMaker BaseElements Tool
FileMaker BaseElements ToolFileMaker BaseElements Tool
FileMaker BaseElements Tool
Mindfire Solutions
 
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
PVS-Studio
 
Session 06 - Java Basics
Session 06 - Java BasicsSession 06 - Java Basics
Session 06 - Java Basics
SiddharthSelenium
 
Types of errors
Types of errorsTypes of errors
Types of errors
Riya Josh
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
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
 
Ppt lesson 06
Ppt lesson 06Ppt lesson 06
Ppt lesson 06
Linda Bodrie
 
Unit 1 - SAP System Architecture
Unit 1 - SAP System ArchitectureUnit 1 - SAP System Architecture
Unit 1 - SAP System Architecture
dubon07
 
Error Correction Techniques
Error Correction TechniquesError Correction Techniques
Error Correction Techniques
Kelly Bauer
 
C and its errors
C and its errorsC and its errors
C and its errors
Junaid Raja
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
mshoaib15
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
RubaNagarajan
 
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
dubon07
 
Applet & graphics programming
Applet & graphics programmingApplet & graphics programming
Applet & graphics programming
Shekh 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 models
Rafael 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 python
roskakori
 
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
PVS-Studio
 
Types of errors
Types of errorsTypes of errors
Types of errors
Riya 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
 

Similar to Module-4_WTA_PHP Class & Error Handling (20)

introduction to php and its uses in daily
introduction to php and its uses in dailyintroduction to php and its uses in daily
introduction to php and its uses in daily
vishal choudhary
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
Alokin Software Pvt Ltd
 
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
AAFREEN SHAIKH
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
PrinceGuru MS
 
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHPLesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
SherinRappai
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
KIRAN KUMAR SILIVERI
 
Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
Mudasir Syed
 
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
Mohd Harris Ahmad Jaal
 
php basic part one
php basic part onephp basic part one
php basic part one
jeweltutin
 
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
jeeva indra
 
Php1
Php1Php1
Php1
poornima sugumaran
 
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGEINTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
Deo Shao
 
Php intro
Php introPhp intro
Php intro
sana mateen
 
Php1
Php1Php1
Php1
poornima sugumaran
 
Php1
Php1Php1
Php1
poornima sugumaran
 
introduction to php and its uses in daily
introduction to php and its uses in dailyintroduction to php and its uses in daily
introduction to php and its uses in daily
vishal choudhary
 
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
AAFREEN SHAIKH
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
PrinceGuru MS
 
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHPLesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
SherinRappai
 
Error reporting in php
Error reporting in php Error reporting in php
Error reporting in php
Mudasir Syed
 
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
Mohd Harris Ahmad Jaal
 
php basic part one
php basic part onephp basic part one
php basic part one
jeweltutin
 
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
jeeva indra
 
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGEINTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
Deo Shao
 
Ad

Recently uploaded (20)

fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Ad

Module-4_WTA_PHP Class & Error Handling

  • 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.
  • 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.
  • 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