WP_HTML_Processor::get_last_error(): string|null

In this article

Returns the last error, if any.

Description

Various situations lead to parsing failure but this class will return false in all those cases. To determine why something failed it’s possible to request the last error. This can be helpful to know to distinguish whether a given tag couldn’t be found or if content in the document caused the processor to give up and abort processing.

Example

$processor = WP_HTML_Processor::create_fragment( '<template><strong><button><em><p><em>' );
false === $processor->next_tag();
WP_HTML_Processor::ERROR_UNSUPPORTED === $processor->get_last_error();

See also

Return

string|null The last error, if one exists, otherwise null.

Source

public function get_last_error() {
	return $this->last_error;
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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