php编码规范个人小结
1.原生态代码或者类的头上,注明作者,关键算法计算过程
例如
/**
*@author zengmoumou
*功能:根据列表ip,取得ip对应的运营商,省,市,县
*/
2.变量尽量用英文单词的组合,第一个小写,后面大写
例如:
$confTreeModel = D("ConfTree");
3.函数名尽量用英文单词的组合,第一个小写,后面大写
例如:
function searchRealServer($keyword)
4.函数之上最好写名该函数的作者,变量,算法
例如:
/**
* @author zengmoumou
* 获得搜索到的结果交换机
* Enter description here ...
* @param unknown_type $allIds
*/
private function getSwitchsInIds($allIds) {
5.函数尽量不要超过100行,如果超过,酌情拆分
6.独立的功能性原生态代码最好分割成 配置页,函数页 ,业务页 。
例如一个读取数据库做汇总的小开发。
可以分割成
config.php 配置页 【书写数据库配置等】
function.php 函数页 【书写各种功能独立的函数,例如读数据函数,构造报表函数,发送邮件函数】
statWeekData.php 业务页 【引用配置页,函数页,依次调用处理各种功能函数处理完业务逻辑】

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

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
