PHP开发手册看云,开发规范 · PHP 开发手册 · 看云

开发时遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范:

* * * * *

[TOC]

* * * * *

### 目录和文件

#### 目录

使用小写+下划线;

#### 类库、函数文件后缀

统一以.php为后缀;

#### 类的文件名

均以命名空间定义,并且命名空间的路径和类库文件所在路径一致;

类文件采用驼峰法命名(首字母大写),其它文件采用小写+下划线命名;

类名和类文件名保持一致,统一采用驼峰法命名(首字母大写);

### 函数和类、属性命名

#### 类的命名

采用驼峰法(首字母大写),例如 User、UserType,默认不需要添加后缀,例如UserController应该直接命名为User;

#### 函数的命名

使用小写字母和下划线(小写字母开头)的方式,例如 get_client_ip;

####方法的命名

使用驼峰法(首字母小写),例如 getUserName;

####属性的命名

使用驼峰法(首字母小写),例如 tableName、instance;

以双下划线“__”打头的函数或方法作为魔法方法,例如 __call 和 __autoload;

### 常量和配置

#### 常量

以大写字母和下划线命名,例如 APP_PATH和 THINK_PATH;

#### 配置参数

以小写字母和下划线命名,例如 url_route_on 和url_convert;

### 数据表和字段

#### 数据表

采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 think_user 表和 user_name字段,不建议使用驼峰和中文作为数据表字段命名。

#### 字段

采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 think_user 表和 user_name字段,不建议使用驼峰和中文作为数据表字段命名。

### 模型命名规则

#### BaseModel

直接命名 Base

#### TableBaseModel

直接命名 Table

#### TableFuncModel

命名为 TableFunc

### 应用类库命名空间规范

应用类库的根命名空间统一为app(可以设置app_namespace配置参数更改);

例如:app\index\controller\Index和app\index\model\User。

序文 I. 入门指引 1. 简介 2. 简明教程 3. 安装 4. 运行时配置 II. 语言参考 5. 基本语法 6. 类型 7. 变量 8. 常量 9. 表达式 10. 运算符 11. 流程控制 12. 函数 13. 类与对象 14. 引用的解释 III. 安全 15. 安全 IV. 特点 16. 用 PHP 进行 HTTP 认证 17. Cookies 18. 文件上传处理 19. 使用远程文件 20. 连接处理 21. 数据库永久连接 22. 安全模式 23. PHP 的命令行模式 V. 函数参考 I. Apache 函数库 II. 数组函数库 III. Aspell functions [deprecated] IV. BCMath Arbitrary Precision Mathematics Functions V. Bzip2 Compression Functions VI. Calendar Functions VII. CCVS API Functions [deprecated] VIII. Windows 的 COM 支持函数库 IX. 类/对象函数库 X. ClibPDF Functions XI. Crack Functions XII. CURL, Client URL Library Functions XIII. Cybercash Payment Functions XIV. Cyrus IMAP administration Functions XV. Character Type Functions XVI. Database (dbm-style) Abstraction Layer Functions XVII. 时间日期函数库 XVIII. dBase Functions XIX. DBM Functions [deprecated] XX. dbx Functions XXI. DB++ Functions XXII. Direct IO Functions XXIII. 目录函数库 XXIV. DOM XML Functions XXV. .NET Functions XXVI. Error Handling and Logging Functions XXVII. File Alteration Monitor Functions XXVIII. FrontBase Functions XXIX. filePro Functions XXX. 文件系统函数库 XXXI. Forms Data Format Functions XXXII. FriBiDi Functions XXXIII. FTP 函数库 XXXIV. Function Handling Functions XXXV. Gettext XXXVI. GMP Functions XXXVII. HTTP 相关函数库 XXXVIII. Hyperwave Functions XXXIX. Hyperwave API Functions XL. iconv Functions XLI. 图像函数库 XLII. IMAP, POP3 and NNTP Functions XLIII. Informix Functions XLIV. InterBase Functions XLV. Ingres II Functions XLVI. IRC Gateway Functions XLVII. PHP / Java Integration XLVIII. LDAP Functions XLIX. LZF Functions L. Mail Functions LI. mailparse Functions LII. 数学函数库 LIII. Multi-Byte String Functions LIV. MCAL Functions LV. Mcrypt Encryption Functions LVI. MCVE Payment Functions LVII. Mhash Functions LVIII. Mimetype Functions LIX. Microsoft SQL Server Functions LX. Ming functions for Flash LXI. Miscellaneous Functions LXII. mnoGoSearch Functions LXIII. mSQL Functions LXIV. MySQL 函数库 LXV. Improved MySQL Extension LXVI. Mohawk Software Session Handler Functions LXVII. muscat Functions LXVIII. Network Functions LXIX. Ncurses Terminal Screen Control Functions LXX. Lotus Notes Functions LXXI. NSAPI-specific Functions LXXII. Unified ODBC Functions LXXIII. Object Aggregation/Composition Functions LXXIV. Oracle 8 函数库 LXXV. OpenSSL Functions LXXVI. Oracle 函数库 LXXVII. Ovrimos SQL Functions LXXVIII. 输出控制函数 LXXIX. Object property and method call overloading LXXX. PDF functions LXXXI. Verisign Payflow Pro Functions LXXXII. PHP Options&Information LXXXIII. POSIX Functions LXXXIV. PostgreSQL 数据库函数库 LXXXV. Process Control Functions LXXXVI. Program Execution Functions LXXXVII. Printer Functions LXXXVIII. Pspell Functions LXXXIX. GNU Readline XC. GNU Recode Functions XCI. 正则表达式函数库(Perl 兼容) XCII. qtdom Functions XCIII. 正则表达式函数库(POSIX 扩展) XCIV. Semaphore, Shared Memory and IPC Functions XCV. SESAM Database Functions XCVI. Session Handling Functions XCVII. Shared Memory Functions XCVIII. SimpleXML functions XCIX. SOAP Functions C. SQLite CI. Shockwave Flash Functions CII. SNMP 函数库 CIII. Socket Functions CIV. Standard PHP Library (SPL) Functions CV. Stream Functions CVI. 字符串处理函数库 CVII. Sybase Functions CVIII. TCP Wrappers Functions CIX. Tidy Functions CX. Tokenizer Functions CXI. URL 函数库 CXII. 变量函数库 CXIII. vpopmail Functions CXIV. W32api 函数库 CXV. WDDX Functions CXVI. XML 语法解析函数库 CXVII. XML-RPC 函数库 CXVIII. xdiff Functions CXIX. XSLT Functions CXX. YAZ Functions CXXI. YP/NIS Functions CXXII. Zip File Functions (Read Only Access) CXXIII. Zlib Compression Functions VI. Zend API 24. Overview 25. Extension Possibilities 26. Source Layout 27. PHP's Automatic Build System 28. Creating Extensions 29. Using Extensions 30. Troubleshooting 31. Source Discussion 32. Accepting Arguments 33. Creating Variables 34. Duplicating Variable Contents: The Copy Constructor 35. Returning Values 36. Printing Information 37. Startup and Shutdown Functions 38. Calling User Functions 39. Initialization File Support 40. Where to Go from Here 41. Reference: Some Configuration Macros 42. API Macros VII. PHP API: 扩展开发接口 43. Streams API for PHP Extension Authors VIII. FAQ: 常见问题 44. 一般信息 45. 邮件列表 46. 获取 PHP 47. 数据库问题 48. 安装 49. 编译问题 50. 使用 PHP 51. PHP 和 HTML 52. PHP 和 COM 53. PHP 和其它语言 54. 从 PHP/FI 2 移植到 PHP 3 55. 从 PHP 3 移植到 PHP 4 56. 杂类问题 IX. 附录 A. PHP 及其相关工程的历史 B. Migrating from PHP 4 to PHP 5 C. 从 PHP 3 移植到 PHP 4 D. 从 PHP/FI 2 移植到 PHP 3 E. PHP 的调试 F. 扩展 PHP 3 G. 函数别名列表 H. 保留字列表 I. 资源类型列表 J. 支持的协议/封装协议列表 K. 所支持的套接字传输器(Socket Transports)列表 L. PHP 类型及比较符表 M. 解析器代号列表 N. 关于本手册 O. Open Publication License P. 函数索引 Q. 补充说明 X. 微软 HTML 帮助版本 57. 关于此版本 58. Using PHP Manual CHM Edition 59. The Full Text Search 60. Specialities of this Edition 61. Integrating the PHP Manual 62. Skin development 63. CHM Edition Credits
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值