Home > Backend Development > PHP Tutorial > php (6) PHP constants

php (6) PHP constants

黄舟
Release: 2023-03-04 11:16:01
Original
958 people have browsed it

1. Custom constants

* Must be defined using the function define()

* After definition, its value cannot be changed

* Use the constant name directly when using it. You cannot add $s

in front like a variable. For example: define("PI",3.14); define a constant

$area = PI*R* R; Calculate the area of ​​a circle

define("URL","http://www.youbml.com");

echo "My URL is:".URL;

2 System constants:

FILE: php program file name

LINE: The number of lines of PHP program files

PHP_VERSION: The version number of the current parser

PHP_OS: The name of the operating system that executes the current PHP version

__FILE__ The name of the script file currently being processed.

__LINE__ The current line number of the script file currently being processed, the same as before.

TRUE represents true value.

FALSE represents a false value (false).

E_ERROR This constant points to the most recent error.

E_WARNING This quantity refers to the nearest warning.

E_PARSE This constant is a potential problem in parsing grammar.

The above is the content of php (6) PHP constants. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template