PHP authoritative Code style specification

Source: Internet
Author: User

1. General
    • Try to unify the IDE such as the Phpstream configuration file (Settings→code Style→php→set from ... →predefined STYLE→PSR1/PSR2) See standard operation
    • Indent must use 4 spaces instead of the TAB key
    • File name StudlyCaps
    • Class name StudlyCaps
    • Constant uppercase words _ delimited words
    • Method Variable Property CamelCase
    • Private Property __ Start
    • The code column is best not to exceed 120
    • No more than 100 rows for a single function
2. Documents
    • File name StudlyCaps
    • Document best Unified Utf-8 without BOM
    • Pure PHP files do not add?> end
3. About line breaks and spaces
    • namespace and use direct class declaration between
    • Empty two lines between property methods
    • Class Method {} Independent account row
    • If while logic code {peer
4. String
    • String contains variables with "" "Pure string with"
    • Long string stitching requires a newline
    • Because PHP "" can carry a variable, so sprintf can not
5. Condition Control
    • Reduce nesting Click to see the case
    • Switch instead of multiple ElseIf "some scenarios can use arrays instead of Swith"
6. About annotations
    • Commenting on the business
7. Additional Rules
    • Use empty () to avoid notice hints when judging uncertainties
Development environment

SVN of the development environment must modify the synchronization to version control main performance two aspects of the problem

    • Common development of the same function
    • Release version Overlay issues

PHP authoritative Code style specification

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.