Home > Article > Backend Development > What are the three naming methods in php
The three naming methods of php are: 1. Little camel case naming method, the first word starts with a lowercase letter, the first letter of the second word is capitalized or the first letter of each word is capitalized ; 2. Pascal nomenclature (also called camel case nomenclature); 3. Hungarian nomenclature, the naming rule is "variable name = attribute type object description".
The operating environment of this tutorial: Windows7 system, PHP7.1 version, DELL G3 computer
Three kinds of php Naming method
1. Camel case naming method:
Camel case (camel method) variables are generally identified with camel case.
The first word starts with a lowercase letter;
The first letter of the second word is capitalized or the first letter of each word is capitalized;
For example: myFirstName
, myLastName
2. Pascal nomenclature (Upper Camel case nomenclature):
Upper Camel case method Case) is also called: Pascal nomenclature: (pascal method) is often used in class names, function names, attributes, and namespaces.
Compared with the small camel case method, the large camel case method also capitalizes the first letter of the first word. For example: public class DataBaseUser
The following are the same function named using camel notation and underscore method respectively:
##printEmployeePaychecks(); Camel style nomenclature - each logical breakpoint in the function name is marked with an uppercase letter
print_employee_paychecks(); underscore method---- Each logical breakpoint in the function name is marked with an underscore.
3. Hungarian nomenclature:
The basic principle is: variable name = attribute type object description. The key to Hungarian nomenclature is: the name of the identifier starts with one or more lowercase letters as a prefix; the prefix is followed by a word or a combination of words with the first letter in capital letters, which should indicate the purpose of the variable. . The Hungarian nomenclature identifies the scope, type, etc. of the variable by adding the corresponding lowercase letter symbol as a prefix in front of the variable name. These symbols can be used multiple times at the same time. The order is m_ (member variables) first, then pointers, then simple data types, and then others. For example: m_lpszStr, represents a long pointer member variable pointing to a string ending with 0 characters. Prefixes of lowercase letters commonly used in Hungarian nomenclature:Prefix typea Array(Array)b Boolean )by Byte(Byte)c Signed Character(Char)cb Unsigned Character(Char Byte, not many people use it)cr color reference value (ColorRef)cx,cy coordinate difference (length ShortInt)dw Double Wordfn functionh Handle(handle )i Integer typel Long Int type(Long Int)lp Long Pointerm_ Class membern Short Int type (Short Int)np Near Pointerp Pointers String typesz Null-terminated string type ( String with Zero End)w WordRecommended learning: "
PHP Video Tutorial"
The above is the detailed content of What are the three naming methods in php. For more information, please follow other related articles on the PHP Chinese website!