The Define () function defines a constant.
The purpose of the Define () function is to define a constant.
Constants is much like variables, except for the following differences:
constants [constant] and variables [variable] have many similarities, so it is easy to confuse; below, we enumerate the differences between constants [constant] and variables [variable]:
A constant ' s value cannot be changed after it is set
A constant value cannot be changed after it has been specified;
constant names do not need a leading dollar sign ($)
When setting constants, you do not need to precede the "$" symbol;
constants can accessed regardless of scope
Constants can be accessed by domains of all scopes;
constant values can only be strings and numbers
The value of a constant can only be "strings [string]" and "numbers [number]";
Syntax
Grammar
Copy the Code code as follows:
Define (name,value,case_insensitive)
Parameter Parameter |
Description Describe |
Name |
Required. Specifies the name of the constant Necessary parameters. Specify the name of the constant |
Value |
Required. Specifies the value of the constant Necessary parameters. Specifying the value of a constant |
Case_insensitive |
Optional. Specifies whether the constant name should be case-insensitive. If set to TRUE, the constant would be case-insensitive. Default is FALSE (case-sensitive) Optional parameters. Specifies whether the name of the constant is case insensitive [case-insensitive]. If set to true, the letter case is not distinguished, and if set to false, the letter case is distinguished. The default value is: False |
Example 1
Case 1
Define a case-sensitive constant:
Specify a constant (case-sensitive):
Copy CodeThe code is as follows:
The output of the code above would be:
The code above will output the following result:
Copy CodeThe code is as follows:
Hello you! How is you today?
Example 2
Case 2
Define a case-insensitive constant:
Specify a constant (case insensitive):
Copy CodeThe code is as follows:
The output of the code above would be:
The code above will output the following result:
Copy CodeThe code is as follows:
Hello you! How is you today?
The defined () function checks whether a constant exists.
The purpose of the defined () function is to check whether a constant exists.
Returns TRUE If the constant exists, or FALSE otherwise.
Returns true if the constant exists, or false if it does not exist.
Syntax
Grammar
Copy the Code code as follows:
Defined (name)
Parameter Parameter |
Description Describe |
Name |
Required. Specifies the name of the constant to check Necessary parameters. Specifies the name of a constant object |
Example
Case
Copy the Code code as follows:
The output of the code above would be:
The code above will output the following result:
Copy the Code code as follows:
1
http://www.bkjia.com/PHPjc/327310.html www.bkjia.com true http://www.bkjia.com/PHPjc/327310.html techarticle the Define () function defines a constant. Define () functions: Defines a constant. Constants is much like variables, except for the following differences: constant [Constan ...