Home > Article > Backend Development > Detailed explanation of the use of define() and defined() functions in php
In the previous article, we introduced the use of define() in php, and the difference between define() and const in php. Today we will continue to introduce the define() function and defined() function in php. The usage is analyzed and introduced in detail, please refer to it if you need it!
The define() function defines a constant.
The define() function defines a constant.
Constants are much like variables, except for the following differences:
Constant [constant] has many similarities with variables [variable], so it is easy to confuse; below, we list the constants [constant] The difference between ] and variable [variable]:
•A constant's value cannot be changed after it is set
A constant value cannot be changed after it is specified;
•Constant names do not need a leading dollar sign ($)
When setting constants, there is no need to add the "$" sign in front;
•Constants can be accessed regardless of scope
Constant values can only be strings and numbers
Constant values can only be strings and numbers String
[string]" and "number[number]";
Syntax
Syntax
The code is as follows:
define(name,value,case_insensitive)
The above is the detailed content of Detailed explanation of the use of define() and defined() functions in php. For more information, please follow other related articles on the PHP Chinese website!