Did the previous article tell you about automatic conversion and forced conversion between PHP data types? Then, this article begins to discuss the constants between PHP constants and variables that restrict users from skipping certain files. What do we know? ? ? Want to know the relationship between them? Then let’s set off together! ! !
The definition of constants in the code is:define
(constant name, constant value)
Supplementary instructions:
1: Constant names can be lowercase or uppercase. Generally speaking, we will use uppercase letters;
2: Constants The name can be without quotation marks; (usually we will add quotation marks)
3: When calling a string constant in a string, it must be outside the quotation marks;
4: It is recommended that the constant name only Use letters and underscores;
The code is as follows:
The execution result is as follows:
(Supplement) About PHP Some system constants:
__FILE__ The relative path of the current PHP file
__DIR__ The directory of the current file
__LINE__ The line number of the current PHP file
__FUNCTION__ Current function name, only effective for calls within the function
__CLASS__ Current class name, only effective for classes
PHP_VERSION Currently used PHP version number
PHP_OS Operating system of the current PHP environment
M_PI Pi constant value
M_E Scientific constant e
E_ERROR Recent errors
E_WARNING Recent warnings
E_PARSE Analysis of potential problems with grammar
__METHOD__ represents the class method name, such as B::test
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of How do you understand the constants between PHP constants and variables to restrict users from skipping certain files?. For more information, please follow other related articles on the PHP Chinese website!