问题
Where can I find PHP coding convention references for PHP coding standards?
回答1:
I suggest Zends Coding Standard: http://framework.zend.com/manual/1.12/en/coding-standard.html
回答2:
The PEAR coding standards have been around for a while now. I believe they are the default for the PHP code sniffer.
回答3:
PSR-2: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
(Excerpt)
This guide extends and expands on PSR-1, the basic coding standard.
The intent of this guide is to reduce cognitive friction when scanning code from different authors. It does so by enumerating a shared set of rules and expectations about how to format PHP code.
回答4:
The ones from Zend are very good.
回答5:
I think there is no official coding standard. I think the ones from Zend are used very often, because they are the company who develop php. But symfony for example, which is a large php mvc framework, has it's own conding standards.
回答6:
I would also like to mention that another popular framework, CakePHP, has their own conventions.
http://book.cakephp.org/view/22/CakePHP-Conventions
回答7:
I would recommend looking at the FLOW3 Coding Guidelines. It is very good.
来源:https://stackoverflow.com/questions/1863790/php-coding-conventions