group-icon
PHP Programming
Group for all things PHP, Coding Help, Problems and Solutions
104 Members
Join this group to post and comment.
AdhikariHarika Reshma
AdhikariHarika Reshma
Computer Science
28 Jan 2019

What are the different errors in PHP?

Basically there are four types of runtime errors in PHP.The error message is sent to the browser with filename, line number and a message describing the error.

1.Notice error:These errors are non critical that php encounters while executing a script. This error occurs mostly while accessing a variable that has not yet been defined.

2. Warning error:These are more serious errors.By default these errors are displayed to the user,but they do not result in  script termination.Mostl my warning errors are due to include a missing file or using the incorrect number of parameters in a function.

3.Fatal error: These are critical errors.These errors cause the immediate termination of script,if we are trying to instantiating an object of a non existent class,or calling a non existent function,then the output is a fatal error that stops the execution of script.

4.Parse error: These are critical errors occurs if there is a syntax mistake in the script.Parse error also stops the execution of script.The common reasons for parse errors are unclosed quotes,missing or extra parentheses, unclosed braces, missing semicolon.

Shruthi Pillai
Shruthi Pillai
Information Technology
2mos ago

Error is the fault or mistake in a program. Error can occur due to wrong syntax or wrong logic.  

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. Parse errors can be caused dues to unclosed quotes, missing or Extra parentheses, Unclosed braces, Missing semicolon etc 

Fatal error

It is the type of error where PHP compiler understand the PHP code but it recognizes an undeclared function. 

Warning error

The main reason of warning errors are including a missing file. 

Notice error

It means that the program contains something wrong but it allows the execution of script.


DHIRAJ LOTLIKAR
DHIRAJ LOTLIKAR
Information Technology
2mos ago

Error occurs during run time of you code if you code is wrong or there is a syntax mistake. The different types of error levels for error handling are,

1) .E_ERROR

Fatal run-time errors. Execution of the script is halted.

2)E_WARNING

Non-fatal run-time errors. Execution of the script is not halted

3) E_PARSE

Compile-time parse errors. Parse errors should only be generated by the parser.

4) E_CORE_ERROR

Fatal errors that occur during PHP's initial start-up.

5)E_USER_ERROR

Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error()

6) E_STRICT

Run-time notices. Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.

7)E_RECOVERABLE_ERROR

Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())

All the above error level can be set using following PHP built-in library function where level cab be any of the value defined in above table.

int error_reporting ( [int $level] )