We can create a constant by using the following define statement.
Define (' constant name ', constant value, case sensitive);
Define (' PI ', 3.14);
Do not write the third parameter the default name of this constant is case-sensitive.
Define (' QI ', 8.14,true);
True indicates that the QI constant is case insensitive.
Use code to demonstrate the following usage.
<?phpdefine (' NUM ', 8), echo Num;echo ' <br> ';d efine (' LENGTH ', 4.56,true); Echo length;//here is the lowercase echo ' <br > ';? >
Points to note:
1. When defining constants with define, constant names are quoted in single quotes.
2. When defining constants with define, constant names cannot be added to the dollar sign. In this case, the constants and variables are completely different.
3. There is no dollar sign when referencing constants. At this point, constants and variables are completely different.
PHP Learning notes-defining constants