3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 = "<?xml version='1.0'?> <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 5.4.0 - 5.5.3
Parse error: syntax error, unexpected 'white' (T_STRING) in /in/eHBRg on line 31
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_STRING in /in/eHBRg on line 31
Process exited with code 255.