×
Copy
Open
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
PHP Coding Style
[email protected]
[email protected]
Slide 2
Slide 2 text
Why? Everyone can easily read your codes just like reading their own codes
Slide 3
Slide 3 text
Spaces is Better than Tabs 4 spaces per indent All Editors have the same indent width Prettier code on Git
Slide 4
Slide 4 text
No ?> In The End of File Only for file with all PHP codes Avoid additional new lines in generated document
Slide 5
Slide 5 text
One Statement Per Line Easier to see changes with side-by-side diff
Slide 6
Slide 6 text
Multiple Line Argument Lists One argument per line Use when have long argument lists
Slide 7
Slide 7 text
Position of Opening and Closing Braces Class and Function declaration in new line Control Structures in the same line
Slide 8
Slide 8 text
Explicit Declaration of Visibility public or protected or private or abstract or static or final
Slide 9
Slide 9 text
Camel Case for Method wowSuchMethod, muchCamel, soCase
Slide 10
Slide 10 text
Friendly Variable Names With Underscore Avoid $j, $i, $asd, $abc, $temp Use $join_table, $counter_product, $temp_collection
Slide 11
Slide 11 text
Thank You source: www.php-fig.org