0% found this document useful (0 votes)
5 views

PHP Error Types (1619)

The document discusses the various types of errors in PHP, categorizing them into four main types: Parse errors, Fatal errors, Warning errors, and Notice errors. Each type is explained with examples and error messages to illustrate common mistakes made by programmers. Understanding these errors is crucial for developers to effectively debug their code and improve application performance.

Uploaded by

samarthpawar9890
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PHP Error Types (1619)

The document discusses the various types of errors in PHP, categorizing them into four main types: Parse errors, Fatal errors, Warning errors, and Notice errors. Each type is explained with examples and error messages to illustrate common mistakes made by programmers. Understanding these errors is crucial for developers to effectively debug their code and improve application performance.

Uploaded by

samarthpawar9890
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Prin.K.P.

Mangalvedhekr Institute of Management,


Career Development and Research Solapur

Name: Ashish Sunil Kamble


Roll no: 1619
Subject: Web Development using PHP
Topic : PHP Error Types
Types of Errors in PHP
Introduction to PHP Errors
Error is the fault or mistake in a program. It can be several types.
Error can occur due to wrong syntax or wrong logic. It is a type of
mistakes or condition of having incorrect knowledge of the code.

There are various types of errors in PHP but it contains basically


four main type of errors.
1.Parse error or Syntax Error:
It is the type of error done by the programmer in the source code of the program. The
syntax error is caught by the compiler. After fixing the syntax error the compiler compile the
code and execute it. Parse errors can be caused dues to unclosed quotes, missing or Extra
parentheses, Unclosed braces, Missing semicolon etc
Example:
<?php
$x = “geeks”;
y = “Computer science”;
echo $x;
echo $y;
?>
Error:

PHP Parse error: syntax error, unexpected ‘=‘


in /home/18cb2875ac563160a6120819bab084c8.php on line 3
Explanation: In above program, $ sign is missing in line 3 so it gives an error message.
2.Fatal Error:
It is the type of error where PHP compiler understand the PHP code but it recognizes an
undeclared function. This means that function is called without the definition of function.
Example:
Error:

PHP Fatal error: Uncaught Error:


Call to undefined function diff()
in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12

Stack trace:
#0 {main}
thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
Explanation : In line 12, function is called but the definition of function is not available. So it
gives error.
3.Warning Errors :
The main reason of warning errors are including a missing file. This means that the PHP
function call the missing file.
Example: Error:
<?php
PHP Warning: include(gfg.php): failed to
open stream: No such file or directory in
$x = “GeeksforGeeks”; /home/aed0ed3b35fece41022f332aba5c9b45.php on
line 5
include (“gfg.php”); PHP Warning: include(): Failed opening ‘gfg.php’
for inclusion (include_path=‘.:/usr/share/php’) in
echo $x . “Computer science portal”; /home/aed0ed3b35fece41022f332aba5c9b45.php on
?> line 5
Explanation: This program call an undefined file gfg.php
which are not available. So it produces error.
4.Notice Error:
It is similar to warning error. It means Error:
that the program contains something
wrong but it allows the execution of PHP Notice: Undefined variable: geeks in
script. /home/
Example: 84c47fe936e1068b69fb834508d59689.php
<?php on line 5
Output:
$x = “GeeksforGeeks”;
GeeksforGeeks
echo $x; Explanation: This program use undeclared
variable $geeks so it gives error message.
echo $geeks;
?>
PHP error constants and their description :

E_ERROR : A fatal error that causes script termination


E_WARNING : Run-time warning that does not cause script termination
E_PARSE : Compile time parse error.
E_NOTICE : Run time notice caused due to error in code
E_CORE_ERROR : Fatal errors that occur during PHP’s initial startup (installation)
E_CORE_WARNING : Warnings that occur during PHP’s initial startup
E_COMPILE_ERROR : Fatal compile-time errors indication problem with script.
E_USER_ERROR : User-generated error message.
E_USER_WARNING : User-generated warning message.
E_USER_NOTICE : User-generated notice message.
E_STRICT : Run-time notices.
E_RECOVERABLE_ERROR : Catchable fatal error indicating a dangerous error
E_DEPRECATED : Run-time notices.
In conclusion, understanding the various types of errors
in PHP is vital for developers. By recognizing syntax,
runtime, fatal, warning, and notice errors, programmers
can debug their code effectively and enhance
application performance. Continuous learning and
adaptation are key to mastering error management in
PHP.

You might also like