3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'XML' <?xml version="1.0"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0"> <title>The name of your data feed</title> <link href="http://www.example.com" rel="alternate" type="text/html" /> <updated>2006-06-11T18:30:02Z</updated> <author> <name>Google</name> </author> <id>tag:example.com,2006-06-11:/support/products</id> <entry> <title>Red wool sweater</title> <id>1a</id> <link href="http://www.example.com/item1-info-page.html" /> <summary>Comfortable and soft, this sweater will keep you warm on those cold winter nights.</summary> <updated>2005-10-13T18:30:02Z</updated> <g:image_link>http://www.google.com/images/google_sm.gif</g:image_link> <g:price>25</g:price> <g:condition>new</g:condition> </entry> </feed> XML; $file = 'data://text/plain;base64,'.urlencode($xml); $fileSize = strlen($xml); $readBytes = 0; $reader = new XMLReader; $reader->open($file); $dom = new DOMDocument(); $xpath = new DOMXpath($dom); $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom'); $xpath->registerNamespace('gi', 'http://base.google.com/ns/1.0'); // look for the first entry element while ($reader->read() && $reader->localName !== 'entry') { continue; } // while you have an entry element while ($reader->localName === 'entry') { $node = $dom->importNode($reader->expand(), TRUE); var_dump( [ 'title' => $xpath->evaluate('string(atom:title)', $entry), 'summary' => $xpath->evaluate('string(atom:summary)', $entry), 'image-link' => $xpath->evaluate('string(gi:image_link)', $entry) ] ); $readBytes += strlen($reader->readOuterXml()); printf( 'Read %s of %s bytes, %d%%', $readBytes, $fileSize, round($readBytes * 100 / $fileSize) ); // move to the next entry sibling $reader->next('entry'); }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: XMLReader::open(data://text/plain;base64,%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Cfeed+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2005%2FAtom%22%0Axmlns%3Ag%3D%22http%3A%2F%2Fbase.google.com%2Fns%2F1.0%22%3E%0A%3Ctitle%3EThe+name+of+your+data+feed%3C%2Ftitle%3E%0A%3Clink+href%3D%22http%3A%2F%2Fwww.example.com%22+rel%3D%22alternate%22+type%3D%22text%2Fhtml%22+%2F%3E%0A%3Cupdated%3E2006-06-11T18%3A30%3A02Z%3C%2Fupdated%3E%0A%3Cauthor%3E%0A%3Cname%3EGoogle%3C%2Fname%3E%0A%3C%2Fauthor%3E%0A%3Cid%3Etag%3Aexample.com%2C2006-06-11%3A%2Fsupport%2Fproducts%3C%2Fid%3E%0A%3Centry%3E%0A%3Ctitle%3ERed+wool+sweater%3C%2Ftitle%3E%0A%3Cid%3E1a%3C%2Fid%3E%0A%3Clink+href%3D%22http%3A%2F%2Fwww.example.com%2Fitem1-info-page.html%22+%2F%3E%0A%3Csummary%3EComfortable+and+soft%2C+this+sweater+will+keep+you+warm+on+those+cold+winter+nights.%3C%2Fsummary%3E%0A%3Cupdated%3E2005-10-13T18%3A30%3A02Z%3C%2Fupdated%3E+%0A%3Cg%3Aimage_link%3Ehttp%3A%2F%2Fwww.google.com%2Fimages%2Fgoogle_sm.gif%3C%2Fg%3Aimage_link%3E+%3Cg%3Aprice%3E25%3C%2Fg%3Aprice%3E+%3Cg%3Acondition%3Enew%3C%2Fg%3Acondition%3E%0A%3C%2Fentry%3E%0A%3C%2Ffeed%3E): Failed to open stream: rfc2397: unable to decode in /in/M6Ycl on line 30 Warning: XMLReader::open(): Unable to open source data in /in/M6Ycl on line 30 Fatal error: Uncaught Error: Data must be loaded before reading in /in/M6Ycl:38 Stack trace: #0 /in/M6Ycl(38): XMLReader->read() #1 {main} thrown in /in/M6Ycl on line 38
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:
56.34 ms | 403 KiB | 8 Q