3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml_reader = \XMLReader::fromString(' <sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd"> <head> <variable name="s"/> <variable name="p"/> </head> <results> <result> <binding name="s"><uri>https://assetmodel.moxio.com/concept/bestaat_uit</uri></binding> <binding name="p"><uri>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</uri></binding> </result> <result> <binding name="s"><uri>https://assetmodel.moxio.com/concept/bestaat_uit</uri></binding> </result> </results> </sparql>'); $success = $xml_reader->next("sparql"); assert($success, "The XML-reply should start with a sparql element"); $success = $xml_reader->read(); assert($success, "It should be possible to move into the sparql element"); $success = $xml_reader->next("head"); assert($success, "The sparql element should contain a head element"); $success = $xml_reader->read(); assert($success, "It should be possible to move into the sparql element"); $success = $xml_reader->next("results"); assert($success, "The sparql element should contain a head element"); while ($xml_reader->read() === true) { if ($xml_reader->next("result") === true) { $result_as_dom_node = $xml_reader->expand(); assert($result_as_dom_node !== false, "The result-element could not be expanded to a dom node"); /** @var \DOMNode $binding_node */ foreach ($result_as_dom_node->childNodes as $binding_node) { if ($binding_node->nodeType === XML_ELEMENT_NODE) { $variable_name = $binding_node->getAttribute("name"); /** @var \DOMNode $binding_value_node */ foreach ($binding_node->childNodes as $binding_value_node) { } } } } }
Output for 8.4.12 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.4.8 - 8.4.11

Process exited with code 139.
Output for 8.2.8 - 8.2.29, 8.3.5 - 8.3.28
Fatal error: Uncaught Error: Call to undefined method XMLReader::fromString() in /in/SaDYr:3 Stack trace: #0 {main} thrown in /in/SaDYr on line 3
Process exited with code 255.

preferences:
74.59 ms | 409 KiB | 5 Q