PHP error_reporting() συνάρτηση

Παράδειγμα

Ορίζει διαφορετικά επίπεδα αναφοράς σφαλμάτων:

<?php
 // Κλείσιμο αναφοράς σφαλμάτων
 error_reporting(0);
 // Αναφορά runtime σφαλμάτων
 error_reporting(E_ERROR | E_WARNING | E_PARSE);
 // Report all errors
 error_reporting(E_ALL);
 // Equivalent to error_reporting(E_ALL);
 ini_set("error_reporting", E_ALL);
 // Report all errors except E_NOTICE
 error_reporting(E_ALL & ~E_NOTICE);
?> 

Definition and Usage

The error_reporting() function specifies which PHP errors should be reported.

The error_reporting() function can set the error_reporting directive at runtime.

PHP has many error levels, and this function can set the level during script execution. If no optional parameter level, error_reporting() will only return the current error reporting level.

Syntax

error_reporting(level);
Parameter Description
level

Optional. Specifies a new error_reporting level. It can be a bitmask or a named constant.

Note:It is strongly recommended to use named constants to ensure compatibility with future versions. Due to the addition of error levels and the increase in integer value ranges, older integer-based error levels may not always behave as expected.

The available error level constants and their actual meanings are described in predefined constants.

Technical Details

Return value: Returns the old error_reporting Level, or at level Returns the current level if no parameters are given.
PHP Version: 4.0+