PHPYou can use predefined constants to obtain information in PHP.
The commonly used predefined constants in PHP are as follows:
Description | |
The default constant is the PHP program file name | |
The default constant is the number of PHP program lines | |
Built-in constants refer to the name of the operating system that executes the PHP parser | |
Built-in constants refer to the version of the PHP program | |
The constant is a true value | |
The constant is a false value | |
A null value | |
Error, causing the php script to terminate | |
Warning will not cause the php script to terminate | |
E_PARSE | Parse errors, reported by the program parser |
E_NOTICE | Non-critical errors, such as variables not initialized |
Note: The "" in FILE and LINE are two underscores, not one "_".
Description: The predefined constants starting with E_ are the error debugging part of PHP.
PHP predefined constant example:
# #There is no difference in usage between predefined constants and user-defined constants. The following uses predefined constants to output information in PHP.
<?php echo "PHP程序当前文件路径名:".FILE; echo "<br >PHP程序当前行数:".LINE; echo "<br >当前PHP程序的版本:".PHP_VERSION; echo "<br >当前操作系统:".PHP_OS; ?>
PHP程序当前文件路径名:D:\phpStudy\www\index.php PHP程序当前行数:3 当前PHP程序的版本:5.6.27 当前操作系统:WINNT
The above is the detailed content of Commonly used predefined constants and examples in PHP. For more information, please follow other related articles on the PHP Chinese website!