WP_HTML_Tag_Processor::get_tag(): string|null

In this article

Returns the uppercase name of the matched tag.

Description

Example:

$p = new WP_HTML_Tag_Processor( '<div class="test">Test</div>' );
$p->next_tag() === true;
$p->get_tag() === 'DIV';

$p->next_tag() === false;
$p->get_tag() === null;

Return

string|null Name of currently matched tag in input HTML, or null if none found.

Source

public function get_tag() {
	if ( null === $this->tag_name_starts_at ) {
		return null;
	}

	$tag_name = substr( $this->html, $this->tag_name_starts_at, $this->tag_name_length );

	return strtoupper( $tag_name );
}

Changelog

VersionDescription
6.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.