【发布时间】:2014-05-30 14:52:51
【问题描述】:
我试图找到一种在 PHP 中处理数据库的 OO 方式,结果发现:https://github.com/adriengibrat/Simple-Database-PHP-Class
在尝试使用它之前,我正在阅读代码,试图准确了解正在做什么(到目前为止失败得很惨)。
一路上我看到了我不习惯看到的以“@”为前缀的 cmets。这是 IDE 会添加的东西,还是在类中评论事物的 OO 方式?以这个 sn-p 为例:
/**
* Get and set default Db configurations
* @uses static::config
* @param string|array $key [Optional] Name of configuration or hash array of configurations names / values
* @param mixed $value [Optional] Value of the configuration
* @return mixed Configuration value(s), get all configurations when called without arguments
*/
static public function config ( $key = null, $value = null ) {
if ( ! isset( $key ) )
return static::$config;
if ( isset( $value ) )
return static::$config[ (string) $key ] = $value;
if ( is_array( $key ) )
return array_map( 'static::config', array_keys( (array) $key ), array_values( (array) $key ) );
if ( isset( static::$config[ $key ] ) )
return static::$config[ $key ];
}
有人能解释一下这些 cmets 的意义吗?
此外,虽然与我的问题无关,但任何人都可以评论这是否是一种以 OO 方式处理数据库的好方法? (请查看上面的链接了解一下)。
谢谢!
【问题讨论】:
-
其实有一个post here,你可以看看。
-
phpdoc.org phpDocumentor 文档块...
-
实际上,这只是一种在脚本头部显示函数正在做什么的乱码方式,而没有在整个脚本中使用普通的伪代码来解释动作。假设您已经在脚本世界中工作了一段时间,并且可以浏览正在使用的逻辑而无需深入评论。
-
@WASasquatch 不是,乱码......“机器可读”。用于从您的代码生成 API 文档,可以将其格式化为 HTML 或其他有用的东西。
-
谢谢大家,我现在就看看重复的主题。同时,有人对我找到的这个数据库类有意见吗?
标签: php