php - 编码约定

标签 php naming-conventions conventions

<分区>

Possible Duplicate:
PHP coding conventions?

是否有任何关于 PHP 的编码约定?我正在寻找特别的命名约定,例如:

For function use nameOfFunction() rather than name_of_function()

For variables don't use $first_array = array() but $array['first'] = array()

Classes should always start with a capital letter: class Name

有吗?难道不应该定义它们,以便不同的程序员现在可以了解整个代码是如何编写的吗?

最佳答案

  1. nameOfFunctionname_of_function - 这完全取决于您。 PHP 本身在这方面甚至没有坚持一致的方案。

  2. 这两者是不同的,不能真正进行比较,尤其是在编码约定的上下文中。

  3. 据我所知,类以大写字母开头的编程语言相当普遍(因此,变量和函数不是)。

编辑:抱歉,我刚刚重新阅读了这个问题,发现您正在寻找更通用的文档。 Zend Coding Standards对此非常好。

关于php - 编码约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5794242/

相关文章:

php - 使用 STS 凭据授权 AWS - 没有 session token

php - 在没有 PDFTK 的情况下合并 FDF 和 PDF

php - 从 JSON 填充选择列表

javascript - 与带下划线的后端同步时,转换为 CamelCase 以便在 JavaScript 中使用?

ruby - Ruby : Should we really believe the style guide? 中的失败与提升

c - 内联汇编程序 : What scratch registers can be used?

php - 在 Wordpress 中向 get_the_date 添加一天

c++ - C++ 标准库中名为 "base"和 "basic"的类的约定是什么?

Magento 源模型约定

c# - 为什么 C# 使用不同的命名约定?