Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
W
wiki-php
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • 互联网应用开发
  • wiki-php
  • Wiki
  • code standard

Last edited by 互联网应用开发 Oct 29, 2024
Page history
This is an old version of this page. You can view the most recent version or browse the history.

code standard

风格要求


//下划线风格,操作符两边空格,字符串单引号
$user_name = '王小名';    

//双引号使用,中间引用的变量需加大括号
$info = "你的姓名:{$user_name}";
//函数 //大括号  , 参数列表空格
function eat_meat($type, $how_much) {  

}

//数组风格
$some_things = array(
    'name'=>'小小',
    'sex'=>'石头'
);
//单行注释

/*
多行
注释
*/


/**
 * 我是整个函数的说明
 * @param string $a  我是a的说明
 * @param int $b  我是b的说明
 * @return int $c  
 */
function im_func($a, $b){
    return $c;
}
//类名首字母大写
//类采用最新的方式 不再有var 这种东西
class Person {
    public $a = 1;
    private function b() {

    }
}

强制规定

  1. 代码风格强制使用上述规则
  2. 函数必须写注释
  3. 不得循环查询数据库
  4. 全局变量使用需通报所有人
  5. 不得在controller里查询数据库 调用Dao
  6. 不得在view层查询数据库
  7. 变量名不得出现拼音
  8. 变量名的长度超过3;
  9. 所有变量使用前须声明
  10. 前端过来的数据谨慎处理,第一时间考虑 注入和跨站的可能性
  11. 待补充

额外推荐

  1. 变量名超过5
  2. 不得对对象使用未声明的属性
  3. 待补充
  4. bll中的方法 尽量避免 get_xxx_by_where这种条件

AJAX返回数据格式

{
    code: 0,1,2,  //返回成功 统一取零
    data: [] | {},  //需要返回的数据
    message:"错误信息说明"
}

Swagger注释文档

swagger php参考地址案例。

Clone repository
  • 360safeguardnativeapi
  • all new classmate
  • bind phone
  • code standard
  • deploy_sys
  • edit common
  • edit master
  • envrioment
  • find psw
  • front new classmate
  • front statck
  • git
  • Home
  • idcard md5
  • ide
View All Pages