PHP Basic code Standard Guideline

PHP Basic code Standard Guideline:

You may also like: Best IDE for PHP Development
Type of Guideline Guideline Description
Start PHP tag All PHP code must be started with
Close PHP tag Closing of PHP tag (?>) should be omitted from script which contain only PHP code.
Encoding All PHP files must use only UTF-8 encoding
Class Naming Convention All class name must be declared in StudlyCaps
Class Constant Naming Convention Class Constants must be declared in UPPERCASE only with underscore.
Class Method Naming Convention Method name must be declared in camelCase
Keyword Naming Convention All PHP constants true, false, and null MUST be in lower case
Code Indentation Code should use 4 spaces for indentation instead of using tabs directly.
Character limit for per Line of code Its always preferable to not use any line limit after certain length. But code lines should be 80 character only or less than that.
Opening and Closing Braces Each opening and Closing braces for each class and method should go to new line only.
Method Visibility Visibility must be declared for all properties and methods. Abstract and Final must be written before visibility. Whereas static should come after visibility.
Uses of space under control keyword (like if,else,switch) Control Structure keyword must have one space after them. The same apply for for, while, switch, try, catch as well. Although the same doesn’t apply for function call.
Opening Closing Braces for Control Structure Opening braces should go on same line of control structure. Closing braces should go to next line of body.
Space after parenthesis for Control Structure There must not be any space after opening or closing parenthesis in any control structure.
Spacing between Method Argument There must be one space after each comma
Space after assigner All variables should have a space separating the assigner
The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video Conferencing and social media domain. The motive of creating cutehits was just to share the knowledge/solutions I get to know during my day to day life so that if possible I can help someone for same problems/solutions. CuteHits.com is a really a very effort for sharing knowledge to rest of the world. For any query/suggestion about same you can contact me on below details:- Email: shekharmca2005 at gmail.com Phone: +91-9560201363

Latest posts by Chandra Shekhar (see all)

You may also like...