WordPress: Function Reference/get comment:修订间差异
来自站长百科
无编辑摘要 |
(→例子) |
||
第26行: | 第26行: | ||
%%%<?php | %%%<?php | ||
## | ##正确的:传递一个需变数作为post_id | ||
$the_comment = & get_comment( $dummy_id = 7 ); | $the_comment = & get_comment( $dummy_id = 7 ); | ||
##不正确的:literal整数作为post_id | ##不正确的:literal整数作为post_id | ||
$the_comment = & get_comment( 7 ); | $the_comment = & get_comment( 7 ); | ||
第35行: | 第33行: | ||
// 致命的错误: '只有变数可以为reference传递' or 'Cannot pass parameter 1 by reference' | // 致命的错误: '只有变数可以为reference传递' or 'Cannot pass parameter 1 by reference' | ||
?>%%% | ?>%%% | ||
== 参数 == | == 参数 == | ||
2008年7月26日 (六) 14:15的最新版本
描述[ ]
获得评论ID,返回文章的数据库记录。你可以根据$output参数,规定结果的返回方式。
用法[ ]
%%%<?php get_comment($id, $output); ?> %%%
例子[ ]
得到评论ID为7的作者名:
%%%<?php $my_id = 7; $comment_id_7 = get_comment($my_id); $name = $comment_id_7->comment_author; ?> %%% 另外,规定$output参数: %%%<?php $my_id = 7; $comment_id_7 = get_comment($my_id, ARRAY_A); $name = $comment_id_7['comment_author']; ?> %%%
%%%<?php
- 正确的:传递一个需变数作为post_id
$the_comment = & get_comment( $dummy_id = 7 );
- 不正确的:literal整数作为post_id
$the_comment = & get_comment( 7 );
// 致命的错误: '只有变数可以为reference传递' or 'Cannot pass parameter 1 by reference' ?>%%%
参数[ ]
返回[ ]
返回的fields是:
- comment_ID
- (integer) 评论 ID
- comment_post_ID
- (integer) 相关文章的ID
- comment_author
- (string)评论作者名
- comment_author_email
- (string)评论作者电子邮件
- comment_author_url
- (string)评论作者网页
- comment_author_IP
- (string)评论作者IP
- comment_date
- (string)评论发表的时间(YYYY-MM-DD HH:MM:SS)
- comment_date_gmt
- (string)评论发表的格林尼治时间(YYYY-MM-DD HH:MM:SS)
- comment_content
- (string)评论的内容
- comment_karma
- (integer)评论的karama
- comment_approved
- (string)评论审核(0, 1 或者 '垃圾广告')
- comment_agent
- (string)评论的代理器(浏览器,操作系统,等等)
- comment_type
- (string)如果评论有意义,显示评论的类型(pingback|trackback),如果为一般的评论,为空
- comment_parent
- (string)上级评论的ID
- user_ID
- (integer) 如果评论作者注册了,为评论作者的ID (否则为0)
参考[ ]
This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.