Naming conventions to be followed in PHP

Source: Internet
Author: User
Naming conventions to be followed in PHP 1. all website construction www.ucantech.com files are ". class. php "is a suffix and the class file name can only contain letters. It is named by the camper method and the first letter is capitalized, for example, DbMysql. class. php. 2. files other than other class library files such as configuration and functions are generally named ". inc. php "and ". php "is a suffix, and the name of the file name is named with lowercase letters and the naming conventions to be followed in PHP
1. all website construction www.ucantech.com files are ". class. php "is a suffix and the class file name can only contain letters. It is named by the camper method and the first letter is capitalized, for example, DbMysql. class. php.

2. files other than other class library files such as configuration and functions are generally named ". inc. php "and ". php "is a suffix, and the name of the file name is named by lowercase letters and underscores. multiple words are separated by an underscore (_), for example, config. inc. php, common. php and install_function.php.

3. ensure that the file name is the same as the call case, because it is case sensitive on Unix-like systems.

4. the class name and file name are the same (including the same case), and only letters are allowed for the class name. for example, the file name of the UserAction class is UserAction. class. the file name of the php and InfoModel classes is InfoModel. class. php.

5. the controller class is suffixed with Action, such as UserAction and InfoAction. The Model class is suffixed with Model, such as UserModel and InfoModel. other classes are also suffixed with corresponding categories, such as Service and Widget.

6. the method name can only consist of letters, underlines are not allowed, the first letter must be lowercase, and then the first letter of each word must be capitalized, that is, the so-called "camper naming" rule, the more detailed the method, the better. you should be able to clearly describe the functions of this method, such as switchModel and findPage.

7. attribute naming can only consist of letters, underlines are not allowed, the first letter must be lowercase, and then the first letter of each word must be capitalized, that is, the so-called "hump naming" rule, for example, tablePrefix and tableName. Fblww-1231)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.