3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Checks if a XML file's structure is valid. * @author Julius Beckmann <php@h4cc.de> * @param $file string * @return bool */ function isXmlStructureValid($file) { $prev = libxml_use_internal_errors(true); $ret = true; try { new SimpleXMLElement($file, 0, true); } catch(Exception $e) { $ret = false; } if(count(libxml_get_errors()) > 0) { // There has been XML errors $ret = false; } // Tidy up. libxml_clear_errors(); libxml_use_internal_errors($prev); return $ret; } $xml = '<html> <head><title>411 Length Required</title></head> <body bgcolor="white"> <center><h1>411 Length Required</h1></center> <center>nginx</center> </body> </html>'; var_dump(isXmlStructureValid($xml));
Output for git.master, git.master_jit, rfc.property-hooks
bool(false)

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:
45.83 ms | 401 KiB | 8 Q