What is the usage of constant in php

王林
Release: 2023-03-10 18:04:01
Original
2519 people have browsed it

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)
Copy after login

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>
Copy after login

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!

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