Home  >  Article  >  Backend Development  >  What is the usage of constant in php

What is the usage of constant in php

王林
王林Original
2021-06-18 16:10:562521browse

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.

What is the usage of constant in php

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:

What is the usage of constant in php

##Related recommendations:

php video tutorial

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!

Statement:
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