Home  >  Article  >  Backend Development  >  How do you understand the constants between PHP constants and variables to restrict users from skipping certain files?

How do you understand the constants between PHP constants and variables to restrict users from skipping certain files?

慕斯
慕斯Original
2021-05-24 10:04:342139browse

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! ! ! How do you understand the constants between PHP constants and variables to restrict users from skipping certain files?

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:

<?php
define(&#39;RS&#39;,&#39;人生若只如初见&#39;);
echo RS;
?>

The execution result is as follows:

How do you understand the constants between PHP constants and variables to restrict users from skipping certain files?

(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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn