WP_Comment::__get │ public │ WP 4.4.0

Magic getter.

If $name matches a post field, the comment post will be loaded and the post's value returned.

Method of the class: WP_Comment{}

No Hooks.

Returns

mixed.

Usage

$WP_Comment = new WP_Comment();
$WP_Comment->__get( $name );
$name(string) (required)
Property name.

Changelog

Since 4.4.0 Introduced.
Since 7.1.0 Returns null instead of the global post's field when the comment is not attached to a post, and no longer raises a warning when the comment's post cannot be found.

WP_Comment::__get() code WP 7.1.2

public function __get( $name ) {
	if ( in_array( $name, $this->post_fields, true ) && 0 !== (int) $this->comment_post_ID ) {
		$post = get_post( (int) $this->comment_post_ID );
		if ( ! $post ) {
			return null;
		}
		return $post->$name;
	}
	return null;
}