Naming rules for method names in php: The first letter of the first word of the method name should be lowercase, and the first letter of subsequent words should be capitalized. The first character of the parameter name in the method should be lowercase, and all subsequent characters should have the first character uppercase according to the class naming rules.
The operating environment of this article: windows10 system, php 7, thinkpad t480 computer.
The function of a method in PHP is to perform an action and achieve a goal, so the name should explain what the method does.
Generally, the prefixes of method names have the first rules, such as is (judgment), get (get), set (set), etc.
Method naming rules:
The first letter of the first word in the method name is lowercase, and the first letter of subsequent words is capitalized.
For example:
class StartStudy{ //设置类 $mLessonOne = ""; //设置类属性 $mLessonTwo = ""; //设置类属性 function getLessonOne(){ //定义方法,得到属性mLessonOne的值 ... } }
Naming rules for parameters in methods:
Use lowercase letters for the first character. All characters after the first character are capitalized according to the class naming convention.
For example:
class EchoAnyWord{ function echoWord($firstWord,$secondWord){ ... } }
Recommended learning:php training
The above is the detailed content of What are the naming rules for method names in php. For more information, please follow other related articles on the PHP Chinese website!