PHP Some basic knowledge of the record
?
PHP define () function
?
Definition and usage
The Define () function defines a constant.
Constants are similar to variables, except that:
- After setting, the value of the constant cannot be changed
- Constant name does not need to start with dollar sign ($)
- Scope does not affect access to constants
- A constant value can only be a string or a number
Grammar:
?
Define (name,value,case_insensitive)
?
Parameter description
Name |
Necessary. Specifies the name of the constant. |
Value |
Necessary. Specifies the value of the constant. |
Case_insensitive |
Optional. Specifies whether the name of the constant is case sensitive. If set to true, the case is not sensitive. The default is False (case sensitive). |
Example
Example 1
Define a case-sensitive constant:
Define ("greeting", "Hello world!"); ECHO constant ("greeting");? >
Output:
Hello world!
Example 2
Defines a case-insensitive constant:
Define ("greeting", "Hello world!", TRUE); Echo constant ("greeting"); >
Output:
Hello world!
?
?