Coding convention [duplicate]
Possible Duplicate:
PHP coding conventions?
Are there any coding conventions regarding PHP? I'm looking for naming convention in particular 开发者_运维百科such as:
For function use
nameOfFunction()
rather thanname_of_function()
or
For variables don't use
$first_array = array()
but$array['first'] = array()
or
Classes should always start with a capital letter:
class Name
Are there any? Shouldn't they be defined so that different programmers will now how the entire code is written?
nameOfFunction
vsname_of_function
- this one is entirely up to you. PHP itself doesn't even stick to a consistent scheme in this regard.Those two things are different, and can't really be compared, especially in the context of coding conventions.
AFAIK, it's fairly common across quite a few programming languages that classes start with a capital letter (and hence, variables and functions don't).
Edit: Sorry, I just re-read the question and saw that you were looking for a more general document. The Zend Coding Standards are pretty good for that.
There are the PEAR Standards
Some standard like Zend Framework's : http://framework.zend.com/manual/en/coding-standard.html
Php_CodeSniffer allows to verify if your code is compatible with some standards and also custom standards.
http://pear.php.net/package/PHP_CodeSniffer/redirected
AFAIK there's no such thing as a document like Python PEPs for PHP code conventions.
Here you have some links from Google searches that try to address this:
http://svn.apache.org/repos/asf/shindig/trunk/php/docs/style-guide.html http://www.phpbuilder.com/columns/tim20010101.php3?page=2
There's this Style Guide frm CodeIgniter web framwrok project, it could work as a guideline in creating some personal or corporate conventions.
Hope this helps, regards.
精彩评论