WordPress:Function Reference/get comment

来自站长百科
Fludlen讨论 | 贡献2008年7月21日 (一) 13:52的版本
跳转至: 导航、​ 搜索

Description

描述

Takes a comment ID and returns the database record for that post. You can specify, by means of the $output parameter, how you would like the results returned.

获得评论ID,返回文章的数据库记录。你可以根据$output参数,规定结果的返回方式。

Usage

用法

%%%<?php get_comment($id, $output); ?> %%%

%%%<?php get_comment($id, $output); ?> %%%

Example

例子

To get the author's name of a comment with ID 7: 得到评论ID为7的作者名: %%%<?php $my_id = 7; $comment_id_7 = get_comment($my_id); $name = $comment_id_7->comment_author; ?> %%%

%%%<?php $my_id = 7; $comment_id_7 = get_comment($my_id); $name = $comment_id_7->comment_author; ?> %%%

Alternatively, specify the $output parameter: 另外,规定$output参数: %%%<?php $my_id = 7; $comment_id_7 = get_comment($my_id, ARRAY_A); $name = $comment_id_7['comment_author']; ?> %%%

%%%<?php


%%%<?php $my_id = 7; $comment_id_7 = get_comment($my_id, ARRAY_A); $name = $comment_id_7['comment_author']; ?> %%%

%%%<?php

    1. Correct: pass a dummy variable as post_id

$the_comment = & get_comment( $dummy_id = 7 );

    1. 正确的:传递一个需变数作为post_id

$the_comment = & get_comment( $dummy_id = 7 );

    1. Incorrect: literal integer as post_id

$the_comment = & get_comment( 7 );

    1. 不正确的:literal整数作为post_id

$the_comment = & get_comment( 7 );

// Fatal error: 'Only variables can be passed for reference' or 'Cannot pass parameter 1 by reference' ?>%%%

// 致命的错误: '只有变数可以为reference传递' or 'Cannot pass parameter 1 by reference' ?>%%%

Parameters

参数

Return

返回

The fields returned are: 返回的fields是:

comment_ID
(integer) The comment ID
comment_ID
(integer) 评论 ID


comment_post_ID
(integer) The post ID of the associated post
comment_post_ID
(integer) 相关文章的ID
comment_author
(string) The comment author's name
comment_author
(string)评论作者名
comment_author_email
(string) The comment author's email
comment_author_email
(string)评论作者电子邮件
comment_author_url
(string) The comment author's webpage
comment_author_url
(string)评论作者网页
comment_author_IP
(string) The comment author's IP
comment_author_IP
(string)评论作者IP
comment_date
(string) The datetime of the comment (YYYY-MM-DD HH:MM:SS)
comment_date
(string)评论发表的时间(YYYY-MM-DD HH:MM:SS)
comment_date_gmt
(string) The GMT datetime of the comment (YYYY-MM-DD HH:MM:SS)
comment_date_gmt
(string)评论发表的格林尼治时间(YYYY-MM-DD HH:MM:SS)
comment_content
(string) The comment's contents
comment_content
(string)评论的内容
comment_karma
(integer) The comment's karma
comment_karma
(integer)评论的karama
comment_approved
(string) The comment approbation (0, 1 or 'spam')
comment_approved
(string)评论审核(0, 1 或者 '垃圾广告')
comment_agent
(string) The comment's agent (browser, Operating System, etc.)
comment_agent
(string)评论的代理器(浏览器,操作系统,等等)
comment_type
(string) The comment's type if meaningfull (pingback|trackback), and empty for normal comments
comment_type
(string)如果评论有意义,显示评论的类型(pingback|trackback),如果为一般的评论,为空
comment_parent
(string) The parent comment's ID
comment_parent
(string)上级评论的ID
user_ID
(integer) The comment author's ID if he is registered (0 otherwise)
user_ID
(integer) 如果评论作者注册了,为评论作者的ID (否则为0)

References

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.

参考

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.