站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
Gallery:编码标准
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
===包装行=== *Break after a comma. *Break before an operator. *Prefer higher-level breaks to lower-level breaks. *Align the new line with the beginning of the expression at the same level on the previous line. *If the above rules lead to confusing code or to code that's squished up against the right margin, just indent 8 columns instead (not 4 columns). Here are some examples of breaking method calls: someMethod(longExpression1, longExpression2, longExpression3, longExpression4, longExpression5); var = someMethod1(longExpression1, someMethod2(longExpression2, longExpression3)); Following are two examples of breaking an arithmetic expression. The first is preferred, since the break occurs outside the parenthesized expression, which is at a higher level. /* '''PREFER''' */ longName1 = longName2 * (longName3 + longName4 - longName5) + 4 * longname6; /* '''AVOID''' */ longName1 = longName2 * (longName3 + longName4 - longName5) + 4 * longname6; Following are two examples of indenting function declarations. The first is the conventional case where the arguments are indented under the open parenthesis. In the second case, the function name is so long that indenting under the parenthesis would require us to put many parameters on their own line which is not visually appealing. But we can't indent the follow on lines by 4 columns because then it would be hard to differentiate them from the code that follows, so we indent them 8 columns, as we do when indenting wrapping if-clauses (see below). /* '''CONVENTIONAL INDENTATION''' */ function someFunction($anArg, $anotherArg, $yetAnotherArg, $andStillAnother) { codeHere; } /* '''INDENT 8 COLUMNS TO AVOID VERY DEEP INDENTS''' */ function superExtraHorkingLongMethodName($anArg, $anArg, $anArg, $anotherArg, $yetAnotherArg, $yetMoreArg, $anArg, $anArg $andStillAnother) { codeHere; } Line wrapping for if statements should generally use the 8 column rule, since conventional 4 column indentation makes it difficult to differentiate the predicate of the if-clause from its condition. For example: /* '''DON'T USE THIS INDENTATION''' */ if ((condition1 && condition2) || (condition3 && condition4) ||!(condition5 && condition6)) { /* BAD WRAPS */ doSomethingAboutIt(); /* MAKE THIS LINE EASY TO MISS */ } /* '''USE THIS INDENTATION INSTEAD''' */ if ((condition1 && condition2) || (condition3 && condition4) ||!(condition5 && condition6)) { doSomethingAboutIt(); } /* '''OR USE THIS''' */ if ((condition1 && condition2) || (condition3 && condition4) ||!(condition5 && condition6)) { doSomethingAboutIt(); } Expressions using the ternary operator should be parenthesized. Here are three acceptable ways to format ternary expressions: $alpha = (aLongBooleanExpression) ? $beta : $gamma; $alpha = (aLongBooleanExpression) ? $beta : $gamma; $alpha = (aLongBooleanExpression) ? $beta : $gamma;
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)