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

More Related Content

PDF
Error handling and debugging
salissal
 
PPTX
Debugging in .Net
Muhammad Amir
 
PPTX
Error handling and debugging in vb
Salim M
 
PPTX
types of error
mansi acharya
 
PPTX
The role of the parser and Error recovery strategies ppt in compiler design
Sadia Akter
 
PPTX
Compiler lecture 04
University of Chitral
 
PPTX
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
dubon07
 
PPTX
Unit 2 - Object Navigator, Repository and ABAP Programs
dubon07
 
Error handling and debugging
salissal
 
Debugging in .Net
Muhammad Amir
 
Error handling and debugging in vb
Salim M
 
types of error
mansi acharya
 
The role of the parser and Error recovery strategies ppt in compiler design
Sadia Akter
 
Compiler lecture 04
University of Chitral
 
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
dubon07
 
Unit 2 - Object Navigator, Repository and ABAP Programs
dubon07
 

What's hot (19)

PPTX
Unit 1 - SAP System Architecture
dubon07
 
PPT
Error Correction Techniques
Kelly Bauer
 
PPTX
C and its errors
Junaid Raja
 
PPTX
What is algorithm
mshoaib15
 
PPT
Java files and io streams
RubaNagarajan
 
PPTX
Unit 3 - Transparent tables in the ABAP Dictionary
dubon07
 
PPT
Applet & graphics programming
Shekh Ahmed
 
PDF
EclipseCon 2015 - Generating business applications from executable models
Rafael Chaves
 
PDF
Ch 9 Attacking Data Stores (Part 2)
Sam Bowne
 
PDF
Helpful logging with python
roskakori
 
PDF
PHP 5
Rafael Corral
 
PDF
FileMaker BaseElements Tool
Mindfire Solutions
 
PDF
Building of systems of automatic C/C++ code logging
PVS-Studio
 
PPTX
Session 06 - Java Basics
SiddharthSelenium
 
PPTX
Types of errors
Riya Josh
 
PPTX
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
PDF
VivaMP, system of detecting errors in the code of parallel C++ programs using...
PVS-Studio
 
PPT
Ppt lesson 06
Linda Bodrie
 
Unit 1 - SAP System Architecture
dubon07
 
Error Correction Techniques
Kelly Bauer
 
C and its errors
Junaid Raja
 
What is algorithm
mshoaib15
 
Java files and io streams
RubaNagarajan
 
Unit 3 - Transparent tables in the ABAP Dictionary
dubon07
 
Applet & graphics programming
Shekh Ahmed
 
EclipseCon 2015 - Generating business applications from executable models
Rafael Chaves
 
Ch 9 Attacking Data Stores (Part 2)
Sam Bowne
 
Helpful logging with python
roskakori
 
FileMaker BaseElements Tool
Mindfire Solutions
 
Building of systems of automatic C/C++ code logging
PVS-Studio
 
Session 06 - Java Basics
SiddharthSelenium
 
Types of errors
Riya Josh
 
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...
PVS-Studio
 
Ppt lesson 06
Linda Bodrie
 
Ad

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

PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPT
KEY PERFORMANCE INDICATOR FOR ICT-UNIT (new)Lect_04c_Detailed_Self_Reading.ppt
SenzotaSemakuwa
 
PDF
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
PDF
Php tutorial from_beginner_to_master
PrinceGuru MS
 
PDF
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
PPTX
PHP ITCS 323
Sleepy Head
 
PPTX
Introduction to PHP.pptx
SherinRappai
 
PPTX
Php unit i
BagavathiLakshmi
 
PDF
Introduction to php
KIRAN KUMAR SILIVERI
 
PPT
Error reporting in php
Mudasir Syed
 
PPTX
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
 
PPTX
php basic part one
jeweltutin
 
PDF
1336333055 php tutorial_from_beginner_to_master
jeeva indra
 
PPTX
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PPTX
Server Scripting Language -PHP
Deo Shao
 
PPTX
Php intro
sana mateen
 
introduction to php and its uses in daily
vishal choudhary
 
KEY PERFORMANCE INDICATOR FOR ICT-UNIT (new)Lect_04c_Detailed_Self_Reading.ppt
SenzotaSemakuwa
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
Php tutorial from_beginner_to_master
PrinceGuru MS
 
Lesson-5-php BY AAFREEN SHAIKH.pdf HSC INFORMATION TECHNOLOGY CHAP 5 PHP
AAFREEN SHAIKH
 
PHP ITCS 323
Sleepy Head
 
Introduction to PHP.pptx
SherinRappai
 
Php unit i
BagavathiLakshmi
 
Introduction to php
KIRAN KUMAR SILIVERI
 
Error reporting in php
Mudasir Syed
 
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
 
php basic part one
jeweltutin
 
1336333055 php tutorial_from_beginner_to_master
jeeva indra
 
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Server Scripting Language -PHP
Deo Shao
 
Php intro
sana mateen
 
Ad

Recently uploaded (20)

PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PDF
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
PDF
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
demidovs1
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PPTX
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
PDF
B.Tech Data Science Program (Industry Integrated ) Syllabus
rvray078
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
VinayB68
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
Software Testing Tools - names and explanation
shruti533256
 
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
demidovs1
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
Ppt for engineering students application on field effect
lakshmi.ec
 
TE-AI-Unit VI notes using planning model
swatigaikwad6389
 
B.Tech Data Science Program (Industry Integrated ) Syllabus
rvray078
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
VinayB68
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 

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