3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = new \SimpleXMLElement(' <blog-post> <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> <tag xmlns:dc="http://purl.org/dc/elements/1.1/"/> </blog-post>' ); $t = microtime(1); for ($i = 0; $i<100000; $i++){ count($xml->xpath('*')); } var_dump(microtime(1)-$t); $t = microtime(1); for ($i = 0; $i<100000; $i++){ $xml->count(); isset($xml->children()->tag); $xml->children()->tag; } var_dump(microtime(1)-$t);

preferences:
40.67 ms | 402 KiB | 5 Q