3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * How to get attribute of node with namespace using SimpleXML? * * @link http://stackoverflow.com/q/6576773/367456 */ $buffer = '<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"><channel><title>Vimeo / Speakers for Schools’s videos</title><link>https://vimeo.com/user29751154/videos</link><description>Videos uploaded by Speakers for Schools on Vimeo.</description><pubDate>Thu, 28 Jan 2016 20:12:40 -0500</pubDate><generator>Vimeo</generator><atom:link rel="self" href="https://vimeo.com/user29751154/videos/rss"/><atom:link rel="hub" href="http://vimeo.superfeedr.com"/><image><url>https://i.vimeocdn.com/portrait/8037598_100x100.jpg</url><title>Vimeo / Speakers for Schools’s videos</title><link>https://vimeo.com/user29751154/videos</link></image> <item><title>Paul Priestman at Gateshead College</title><pubDate>Tue, 15 Dec 2015 05:21:31 -0500</pubDate><link>https://vimeo.com/148993338</link><description>&lt;p&gt;&lt;iframe src=&quot;https://player.vimeo.com/video/148993338&quot; width=&quot;640&quot; height=&quot;360&quot;frameborder=&quot;0&quot; title=&quot;Paul Priestman at Gateshead College&quot; webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;&lt;/p&gt;&lt;p&gt;&lt;p class=&quot;first&quot;&gt;Paul Priestman, Designer &amp; Co-Director of PriestmanGoode, visited Gateshead College for a talk as part of the Speakers for Schools program. This video has been provided courtesy of Steven Chippendale, from the school.&lt;/p&gt; &lt;p&gt;Speakers for Schools is an independent UK charity that provides state secondary schools with access to talks from high-profile professionals and academics. Our speakers are experts and leaders in their fields: some of the countrys highest achieving individuals across government, business, sport, technology, science and the arts, donating their time to share their insights and experiences. For more information visit our website at speakers4schools.org&lt;/p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Cast:&lt;/strong&gt; &lt;a href=&quot;https://vimeo.com/user29751154&quot;&gt;Speakers for Schools&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;a href=&quot;https://vimeo.com/tag:business&quot;&gt;business&lt;/a&gt;, &lt;a href=&quot;https://vimeo.com/tag:Gateshead&quot;&gt;Gateshead&lt;/a&gt;, &lt;a href=&quot;https://vimeo.com/tag:Paul+Priestman&quot;&gt;Paul Priestman&lt;/a&gt;, &lt;a href=&quot;https://vimeo.com/tag:design&quot;&gt;design&lt;/a&gt; and &lt;a href=&quot;https://vimeo.com/tag:Gateshead+College&quot;&gt;Gateshead College&lt;/a&gt;&lt;/p&gt;</description><guid isPermaLink="false">tag:vimeo,2015-12-15:clip148993338</guid><media:content><media:player url="https://player.vimeo.com/video/148993338"/><media:credit role="author" scheme="https://vimeo.com/user29751154"></media:credit><media:thumbnail height="540" width="960" url="https://i.vimeocdn.com/video/548100055_960.jpg"/><media:title>Paul Priestman at Gateshead College</media:title></media:content></item> </channel></rss>'; $xml = new SimpleXMLElement($buffer); if (!defined('LIBXML_DOTTED_VERSION')) { echo "PHP/LIBXML unsupported/too old."; return; } echo "ibxml version: ", LIBXML_DOTTED_VERSION, "\n"; $youtube = $xml; echo 'tests: ', $youtube->rss->channel->item, "\n"; echo 'via attributes(): ', $youtube->channel->item->children('media', TRUE)->content, "\n"; echo 'via array-access: ', $youtube->channel->item->children('media', TRUE)->content, "\n"; echo 'via property : ', $youtube->channel->item->children('media', TRUE)->content, "\n";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
ibxml version: 2.9.4 tests: Warning: Attempt to read property "item" on null in /in/4AgL9 on line 23 via attributes(): via array-access: via property :
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 ibxml version: 2.9.4 tests: Warning: Attempt to read property "item" on null in /in/4AgL9 on line 23 via attributes(): via array-access: via property :
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
ibxml version: 2.9.4 tests: Notice: Trying to get property 'item' of non-object in /in/4AgL9 on line 23 via attributes(): via array-access: via property :
Output for 7.3.32 - 7.3.33
ibxml version: 2.9.4 tests: via attributes(): via array-access: via property :
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
ibxml version: 2.9.4 tests: Notice: Trying to get property of non-object in /in/4AgL9 on line 23 via attributes(): via array-access: via property :

preferences:
264.96 ms | 402 KiB | 330 Q