SlideShare a Scribd company logo
1 of 14
Download to read offline
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

More Related Content

What's hot

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
 

What's hot (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
 

Similar to Module-4_WTA_PHP Class & Error Handling

Similar to Module-4_WTA_PHP Class & Error Handling (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
 

Recently uploaded

Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...Amil baba
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfragupathi90
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New HorizonMorshed Ahmed Rahath
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Toolssoginsider
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological universityMohd Saifudeen
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfKira Dess
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.benjamincojr
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docxrahulmanepalli02
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Studentskannan348865
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksIJECEIAES
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfSkNahidulIslamShrabo
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualBalamuruganV28
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUankushspencer015
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniR. Sosa
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...drjose256
 
History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationEmaan Sharma
 

Recently uploaded (20)

Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx21P35A0312 Internship eccccccReport.docx
21P35A0312 Internship eccccccReport.docx
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 

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