In php, what are the special meanings of variables and functions whose names start with an underscore? This is often seen in other people's frameworks, but what are the advantages of doing so? In php, what are the special meanings of variables and functions whose names start with an underscore?
This is often seen in other people's frameworks, but what are the advantages of doing so?
Reply content:
In php, what are the special meanings of variables and functions whose names start with an underscore?
This is often seen in other people's frameworks, but what are the advantages of doing so?
The framework starts the variable name and function name with _ to avoid conflicts with the user's name.
You can also start with _ to indicate private methods or attributes.
You can find:
Meanings of variables starting with an underscore in PHP
View PHP naming rules and development suggestions from "ThinkPHP development specifications"
An underline is a private variable and a private method.
The two underscores are built-in PHP variables.
It is a private member of the class.
This is just an unwritten rule. the benefit is enhanced readability. as soon as you see the name starting with the line below, it is a private member.
It should be from another language, suchC ++
,Java
.