
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to display errors in PHP file?
A PHP application produces many levels of errors during the runtime of the script . So in this article, we will learn how to display all the errors and warning messages.
The quickest way to display all php errors and warnings is to add these lines to your PHP code file:
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
The ini_set function will try to override the configuration found in your php.ini file. If in the php.ini file display_error is turned off it will turn that on in the code. It also set display_startup_errors to true to show the error message. error_reporting() is a native PHP function that is used to display the errors. By setting it true it displays the error that occurs in the code.
But there is an again question arises what is E_ALL? The answer is simple PHP code produces different levels of errors. So let's learn what are those types of errors occurs in a PHP code.
E_ERROR :
fatal runtime error execution of script has been haltedE_WARNING :
nonfatal runtime error execution of script has been haltedE_PARSE :
compile time error it is generated by the parserE_NOTICE :
The script found something that might be an errorE_CORE_ERROR :
Fatal errors that occurred during the initial startup of scriptE_CORE_WARNING :
Nonfatal errors that occurred during the initial startup of scriptE_ALL :
All errors and warningUnfortunately, the above code we have composed won't almost certainly show parse errors, for example, missing semicolons or missing wavy supports. For this situation, the php.ini setup must be altered.
display_errors = on
The display_errors order must be set to "on" in the php.ini document. This will show every one of the errors including syntax or parse mistakes that can't be shown by simply calling the ini_set work in the PHP code.
So in the above way, we can display errors in our php application.
- Related Articles
- PHP Errors in PHP7
- PHP Types of Errors
- How to echo XML file in PHP
- How to import csv file in PHP?
- How to display XML in HTML in PHP?
- How to display two decimals in MySQL/PHP?
- How to force file download with PHP?
- How to convert XML file into array in PHP?
- PHP file://
- How to call Python file from within PHP?
- How to parse a CSV file using PHP
- How to get file name from a path in PHP?
- file() function in PHP
- Upload file with php to another php server
- How to catch syntax errors in JavaScript?
