In PHP, you can use predefined constants to obtain information in PHP. Common predefined constants are as follows: In PHP, you can use predefined constants to obtain information in PHP.
Common predefined constants in PHP are as follows:
Constant name |
Description |
_ FILE __ |
The default constant is the PHP program file name. |
_ LINE __ |
Default constant, which is the number of PHP programs |
PHP_ OS |
A built-in constant is the name of the operating system that executes the PHP parser. |
PHP_VERSION |
The built-in constant is the PHP program version. |
TRUE |
This constant is a true value. |
FALSE |
This constant is a dummy value. |
NULL |
A null value |
E_ERROR |
Error, resulting in termination of php script |
E_WARNING |
Warning, does not cause the php script to stop running |
E_PARSE |
Parsing error reported by the program parser |
E_NOTICE |
Non-critical errors, such as variable not initialized |
Note: "" in FILE and LINE is two underscores rather than one "_".
Note: predefined constants starting with E _ are part of PHP error debugging.
PHP pre-defined constant instance:
The usage of predefined constants is no different from that of custom constants. The following uses a predefined constant to output information in PHP.
Current number of PHP programs: ". LINE; echo"
Current PHP program version: ". PHP_VERSION; echo"
Current operating system: ". PHP_ OS;?>
The output result is similar to the following:
PHP program current file path: D: \ phpStudy \ www \ index. phpPHP program current number of lines: 3 current PHP program version: 5.6.27 current operating system: WINNT
Note: The results may vary depending on the operating system and software version used by each user.
The above are common predefined constants and instance details in PHP. For more information, see other related articles in the first PHP community!