3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlString = '<root><item>Hibás XML</item>'; // Hiányzó záró tag. // Átvesszük az irányítást a hibakezelés felett, ez elnyomja az E_WARNING-ot. $previously = \libxml_use_internal_errors(true); try { return new \SimpleXMLElement($xmlString, \LIBXML_NONET | \LIBXML_NOCDATA | \LIBXML_NOBLANKS); } catch (\Throwable $e) { // Begyűjtjük a részletes hibákat a libxml pufferről. $errors = \array_map(static function (\LibXMLError $error): string { $level = match ($error->level) { LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal Error', default => 'Unknown', }; return \sprintf('[%s] %s (%d:%d)', $level, \trim($error->message), $error->line, $error->column); }, \libxml_get_errors()); \libxml_clear_errors(); throw new \InvalidArgumentException( \sprintf('SimpleXMLElement parsing failed (%s).', \implode(', ', $errors)), 0, $e, ); } finally { // Visszaállítjuk az eredeti hibakezelési állapotot. \libxml_use_internal_errors($previously); }
Output for git.master_jit, git.master
Fatal error: Uncaught Exception: String could not be parsed as XML in /in/mCsGl:9 Stack trace: #0 /in/mCsGl(9): SimpleXMLElement->__construct('<root><item>Hib...', 18688) #1 {main} Next InvalidArgumentException: SimpleXMLElement parsing failed ([Fatal Error] Premature end of data in tag root line 1 (1:29)). in /in/mCsGl:25 Stack trace: #0 {main} thrown in /in/mCsGl on line 25
Process exited with code 255.

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:
28.21 ms | 406 KiB | 5 Q