【转】谭博的个人网站
<pre class="brush:php;toolbar:false;" [类]
<pre class="brush:php;toolbar:false;" <pre class="brush:php;toolbar:false;"登录后复制<pre class="brush:php;toolbar:false;" 函数名使用小写字母加下划线<pre class="brush:php;toolbar:false;" <pre class="brush:php;toolbar:false;" [缩进]登录后复制<pre class="brush:php;toolbar:false;" 函数方法中代码块缩进4个空格<pre class="brush:php;toolbar:false;" 语句如foreach switch后需加一个空格登录后复制<pre class="brush:php;toolbar:false;" 定义函数,方法名时加一个空格,如 function test() {<pre class="brush:php;toolbar:false;" 函数调用时不使用缩进,如 :test();登录后复制<pre class="brush:php;toolbar:false;" 函数或方法有多个参数时需在逗号后面加一个空格,如test($a, $b, $c);<pre class="brush:php;toolbar:false;" 赋值运算等号前后需要一个空格,如:$a = ‘b’;登录后复制<pre class="brush:php;toolbar:false;" 三目运算需使用空格分割,如:$a = 1 ? 2 : 3;<pre class="brush:php;toolbar:false;" 逻辑运算符前后需要一个空格,如:($a == $b)登录后复制<pre class="brush:php;toolbar:false;" 如碰到需要换行的情况,以4个空格开头<pre class="brush:php;toolbar:false;"登录后复制<pre class="brush:php;toolbar:false;" [换行]<pre class="brush:php;toolbar:false;" 每行代码最大长度建议值为85,不要超过100登录后复制<pre class="brush:php;toolbar:false;" 尽量使用简洁的变量名,如果代码过长可使用赋值的方式将其分解<pre class="brush:php;toolbar:false;" 如果优化后还是过长,可使用换行登录后复制<pre class="brush:php;toolbar:false;" 非数字元素数组建议一行一个元素<pre class="brush:php;toolbar:false;"登录后复制<pre class="brush:php;toolbar:false;" [注释]<pre class="brush:php;toolbar:false;" 行注释用登录后复制<pre class="brush:php;toolbar:false;" 代码块注释使用登录后复制<pre class="brush:php;toolbar:false;" <pre class="brush:php;toolbar:false;" [代码优化]登录后复制<pre class="brush:php;toolbar:false;" 尽量减少if else语句的嵌套,一是为了减少代码的缩进,二是减轻逻辑复杂度登录后复制
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号