PHP programming naming convention

WBOY
Release: 2016-07-25 09:00:01
Original
990 people have browsed it
  1. printEmployeePaychecks();
  2. print_employee_paychecks();
Copy code

The first function name uses camel notation - each logical breakpoint in the function name has a capital letter to mark; the second function name uses the underscore method - each logical breakpoint in the function name is marked with an underscore. Camel notation has become more and more popular in recent years. It is used quite a lot in many new function libraries and environments such as Microsoft Windows. On the other hand, the underscore method became popular after the emergence of c. It is very commonly used in many old programs and environments such as UNIX.

Camel-Case is a set of naming rules (conventions) when writing computer programs. Camel-style nomenclature is when a variable name or function name is a unique identifier composed of one or more words connected together. The first word starts with a lowercase letter; the first letter of the second word is capitalized or each The first letters of a word are all capital letters, for example: myFirstName, myLastName. Such variable names look like camel humps rising one after another, hence the name.

The word Camel-Case comes from the mixed-case format commonly used in the Perl language, and the cover picture of the best-selling book "Programming Perl" (published by O'Reilly) written by Larry Wall et al. It's a camel. The naming rules of camel nomenclature can be regarded as a convention, not absolute or mandatory, in order to increase recognition and readability.

Camel hump method (small hump method)

Variables are generally identified using camel case. CamelCase means capitalizing the first letter of every word except the first word. for example

    int myStudentCount;
Copy code
The first word of the variable myStudentCount is all lowercase, and the first letter of the following words is capitalized.

Pascal method (big camel method)

Compared with the small camel case method, the large camel case method also capitalizes the first letter of the first word. Commonly used in class names, function names, attributes, and namespaces. for example

    publicclass DataBaseUser;
Copy code
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template