WP_HTML_Processor::get_last_error()publicWP 6.4.0

Returns the last error, if any.

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();

Method of the class: WP_HTML_Processor{}

No Hooks.

Return

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

Usage

$WP_HTML_Processor = new WP_HTML_Processor();
$WP_HTML_Processor->get_last_error();

Notes

  • See: self::ERROR_UNSUPPORTED
  • See: self::ERROR_EXCEEDED_MAX_BOOKMARKS

Changelog

Since 6.4.0 Introduced.

WP_HTML_Processor::get_last_error() code WP 6.6.2

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