Home >Backend Development >PHP Problem >What is the usage of constant in php
The usage of constant in php is [constant(constant)]. The constant in parentheses specifies the name of the constant to be checked. If this constant is undefined, the function returns NULL.
The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.
There is a function constant in php. This function can return the value of a constant. If the constant is not defined, it returns NULL. Some friends may not understand this function. Let's take a look at the usage of this function.
Function syntax:
constant(constant)
The constant here is the name of the constant to be checked.
Code example:
<!DOCTYPE html> <html> <body> <?php //define a constant define("GREETING","Hello you! How are you today?"); echo constant("GREETING"); ?> </body> </html>
The running effect is as follows:
The above is the detailed content of What is the usage of constant in php. For more information, please follow other related articles on the PHP Chinese website!