Table of Contents
https://code.google.com/p/google-styleguide/ http://lxr.linux.no/linux/Documentation/CodingStyle http://perldoc.perl.org/perlstyle.html http://www.gnu.org/prep/standards/
使用 UNIX 风格换行, 请在你的编辑器内调整
UNIX (LF或"\n") MAC OS (CR 或"\r") Windows CRLF \r\n
源码文件使用 UTF-8
有些IDE环境 UTF-8 BOM
if, while, for, foreach, do ... loop, switch... 等的嵌套必须小于等于3层
如下面的例子,可读性极差。
if (xxx){
if (xxx){
if(xxx){
if(xxx){
if(xxx){
}
}
}
if(xxx){
if(xxx){
}
}
}
if (xxx){
if(xxx){
if(xxx){
}
}
if(xxx){
if(xxx){
}
}
}
}
加以改造
func aaa(p){
if(p){
if(xxx){
}
}
}
func bbb(b){
if(b){
if(xxx){
if(xxx){
}
}
}
}
if(xxx){
aaa(xxx)
}
if(b){
bbb(b)
}
<?php /** * Project Name * * @author $Author: netkiller $ * @copyright Copyright (c) 2012 Company * @version $Id: chapter.coding.xml 584 2013-05-15 05:13:17Z netkiller $ */ <?php /** * Project Name * * @author $Author: netkiller $ * @license GNU General Public License 2.0 * @version $Id: chapter.coding.xml 584 2013-05-15 05:13:17Z netkiller $ */