php编程命名规则
命名是程序规划的核心。古人相信只要知道一个人真正的名字就会获得凌驾于那个人之上的不可思议的力量。只要你给事物想到正确的名字,就会给你以及后来的人带来比代码更强的力量。别笑!
名字就是事物在它所处的生态环境中一个长久而深远的结果。总的来说,只有了解系统的程序员才能为系统取出最合适的名字。如果所有的命名都与其自然相适合,则关系清晰,含义可以推导得出,一般人的推想也能在意料之中。
如果你发觉你的命名只有少量能和其对应事物相匹配的话, 最好还是重新好好再看看你的设计吧。
类命名
在为类( 0;
}
--------------------------------------------------------------------------------
函数命名
函数名字采用C GNU的惯例,所有的字母使用小写字母,使用'_'分割单词。
理由
这样可以更易于区分相关联的类名。
例如
function some_bloody_function()
{
}
--------------------------------------------------------------------------------
错误返回检测规则
检查所有的系统调用的错误信息,除非你要忽略错误。
为每条系统错误消息定义好系统错误文本以便include。
--------------------------------------------------------------------------------
大括号 {} 规则
在三种主要的大括号放置规则中,有两种是可以接受的,如下的第一种是最好的:
将大括号放置在关键词下方的同列处:
if ($condition) while ($condition)
{ {
... ...
} }
传统的UNIX的括号规则是,首括号与关键词同行,尾括号与关键字同列:
if ($condition) { while ($condition) {
... ...
} }
理由
引起剧烈争论的非原则的问题可通过折衷的办法解决,两种方法任意一种都是可以接受的,然而对于大多数人来说更喜欢第一种。原因就是心理研究学习范畴的东西了。
对于更喜欢第一种还有着更多的原因。如果您使用的字符编辑器支持括号匹配功能的话(例如vi),最重要的就是有一个好的样式。为什么?我们说当你有一大块的程序而且想知道这一大块程序是在哪儿结束的话。你先移到开始的括号,按下按钮编辑器就会找到与之对应的结束括号,例如:
if ($very_long_condition && $second_very_long_condition)
{
...
}
else if (...)
{
...
}
从一个程序块移动到另一个程序块只需要用光标和你的括号匹配键就可以了,不需要来回的移动到行末去找匹配的括号。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version
