Predefined constants

The predefined constants (always available) are:

__FILE__ (case-insensitive)

The name of the script file presently being parsed. If used within a file which has been included or required, then the name of the included file is given, and not the name of the parent file.

__LINE__ (case-insensitive)

The number of the line within the current script file which is being parsed. If used within a file which has been included or required, then the position within the included file is given.

PHP_VERSION

The string representation of the version of the PHP parser presently in use; for example '4.1.0'.

PHP_OS

The name of the operating system on which the PHP parser is executing;. Possible values may be : "AIX", "Darwin" (MacOS), "Linux", "SunOS", "WIN32", "WINNT". Note: other values may be available too.

TRUE (case-insensitive)

A TRUE value (see the boolean type).

FALSE (case-insensitive)

A FALSE value (see the boolean type).

NULL (case-insensitive)

A NULL value (see the null type).

E_ERROR

Denotes an error other than a parsing error from which recovery is not possible.

E_WARNING

Denotes a condition where PHP knows something is wrong, but will continue anyway; these can be caught by the script itself. An example would be an invalid regexp in ereg().

E_PARSE

The parser choked on invalid syntax in the script file. Recovery is not possible.

E_NOTICE

Something happened which may or may not be an error. Execution continues. Examples include using an unquoted string as an array index, or accessing a variable which has not been set.

E_ALL

All of the E_* constants rolled into one. If used with error_reporting(), will cause any and all problems noticed by PHP to be reported.

The E_* constants are typically used with the error_reporting() function for setting the error reporting level. See all these constants at Error handling.

Example 8-2. Using __FILE__ and __LINE__


<?php
function report_error($file, $line, $message)
{
    echo "An error occured in $file on line $line: $message.";
}

report_error(__FILE__, __LINE__, "Something went wrong!");
?>