Constant:
1. Concept
Constants are containers that store values (data) for temporary (only when our program is running)
2. Definition and use
Define (' constant name ', constant value) or define ("constant name", constant value)
Name of the constant:
1) can only contain alphanumeric underscores and must start with a letter or underscore
2) By convention constant names are always capitalized
3) Custom constants are strictly case-sensitive!
Defined () function to check if a constant is defined
3. The difference between constants and variables
1) No dollar sign ($) before constant
2) constants can only be defined with the Define () function and cannot be evaluated by an assignment statement
3) ******** constants can be defined and used anywhere without regard to the rules of variable scope
4) constants cannot be redefined or undefined once they are defined
5) The value of a constant can only be a bool,int,float,string type
4. Pre-defined constants
Predefined constants Well, that's the constant that our PHP kernel has already defined for us!
Some of the predefined constants are the beginning of a __, and these predefined constants we call it Magic constants
The code is in a different location and his value is different, so it adds magic constants.
Eight Common Magic constants
http://php.net/manual/zh/language.constants.predefined.php
Predefined constants are case-insensitive!
Define (' Constant name ', constant value); Define ("Constant name", constant value);
Example:
<? PHP $a= ' 90 web forum '; Define (' My_name ', ' 90 web forum '); Echo my_name;? >
90 Web Forum PHP Basics