Naming conventions for PHP

Source: Internet
Author: User
Tags php class
1. Class

The class name is capitalized in the first letter of each word, such as the class name Studentcourse.

2. Constants

The constant name is all uppercase letters, the words are separated by underscores, and the usual names are null, TRUE, FALSE, Root_path, and so on.

3. Variables

In order to ensure the good readability of the code, general requirements in the same software system, the naming principle of variables must be unified.

If the name of the variable can be the first letter lowercase, the rest of the first letter capital (hump);

You can also use the word all letters lowercase, the words are divided by underscores.

4. Arrays

An array is a container in which multiple data elements can be stored, so in an array name, try to use the plural form of the word.

such as $words, $numbers, $colors.

5. Functions

The naming conventions for functions are the same as the naming conventions for variable names. Normally functions perform an action, so when a function is named, a verb is included in the general function.

such as the function name GetName, SetName.

6. database table field

The naming conventions for the database table fields are the same as the naming conventions for the two-name transformation.

7. class files

PHP class files are usually named with a. class.php suffix, and the file name and class name are the same.

such as Student.class.php.

Naming conventions for PHP

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.