Php and database code development specifications

Source: Internet
Author: User
Php and database code development specifications

1/25/2016 6:00:31

Php naming rules for various variables
  1. Directory name file name local variable name
    1. Use English verb nouns and underscores (_) to separate words. all letters are in lower case.
    2. Directory upload templates install manage
    3. File index. php register. php config. php
    4. $ User $ pay_time
  2. Global variables use English name, word, and verb names in uppercase, and use underscores to separate them.

    Standardization of function symbol operation writing in php
  3. Array variable name English name word verb underline split all letters lowercase end with array $ book_id_array
  4. Object variable name complete class name or simplified class name all letters in lowercase after the variable add _ obj $ user_obj
  5. Class naming uses English names to Separate uppercase and lowercase letters. Other letters use lowercase letters. The first letter of a noun uses lowercase letters and does not apply to underlines $ class userAccount {}
  6. Method naming nouns, verbs, and underscores (_) are used as words to separate all letters in lowercase.

    Class userAccount {
    Public $ name_account = "";
    Function is_account_ OK (){
    }
    Function add_account (){
    }}

  7. When break is added to each case module of the switch, the default should always handle unknown situations.
  8. To declare and locate a rule declaration code block, you need to initialize it for the first time when using variables.

    $tableName       ='';$databaseObject  ='';
  9. The elements of form should be consistent with the database fields whenever possible. do not use the default square test method to test that the non-zero value must be displayed.

    If ($ name_pay! = False ){
    } Else {}
  10. Use more single quotes and use less double quotes
  11. Try to separate php from html during Template development
  12. Generally, each method only executes one logical action. The transaction name should be clear about what they do. use email_error_check () instead of error_check ()

    Various php annotation specifications
    /*** Paging preprocessing function * SQL statement * page current page number * Total number of maxs queries */function limit ($ SQL, $ page = '0', $ limit = 10, $ maxs = '') {}// user detection if ($ check_obj-> username ($ username) = true ){......} $ User_name = $ _ GET [user]; // GET user information
Database design and operation specifications
  1. Data name: lowercase English name words to avoid cross-platform case-insensitive
  2. Data table: lowercase English words of object names separated by underscores (_)
  3. Data table field: Avoid using varchar text and other indefinite long-time fields to store data in int type.
  4. When querying data to connect multiple tables, the full name of each resource is tableName, fieldName instead of fieldName.
  5. SQL statements should comply with the ansi92 standard as much as possible to avoid using specific databases to supplement SQL features

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.