3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '<p>I am <30 years old and weight <12st</p>'; $libxmlErrorState = libxml_use_internal_errors(true); function getLastErrorPos($code) { $errors = array_filter(libxml_get_errors(), function ($e) use ($code) { return $e->code === $code; }); if ( !$errors ) return false; $lastError = array_pop($errors); return ['line' => $lastError->line - 1, 'column' => $lastError->column - 2 ]; } define('XML_ERR_NAME_REQUIRED', 68); // xmlParseEntityRef: no name $patternTemplate = '~(?:.*\R){%d}.{%d}\K<~A'; $dom = new DOMDocument; $dom->loadHTML($s, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); while ( false !== $position = getLastErrorPos(XML_ERR_NAME_REQUIRED) ) { libxml_clear_errors(); $pattern = vsprintf($patternTemplate, $position); $s = preg_replace($pattern, '&lt;', $s, 1); $dom = new DOMDocument; $dom->loadHTML($s, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); } echo $dom->saveHTML(); libxml_clear_errors(); libxml_use_internal_errors($libxmlErrorState);
Output for git.master, git.master_jit, rfc.property-hooks
<p>I am &lt;30 years old and weight &lt;12st</p>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
71.96 ms | 401 KiB | 8 Q