3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = <<<ENDXML <?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>Cricinfo Live Scores</title> <ttl>2</ttl> <link>http://www.cricinfo.com</link> <description>Latest scores from Cricinfo</description> <copyright>(c)Cricinfo</copyright> <language>en-gb</language> <pubDate>Fri, 23 Feb 2018 04:07:02 +0000</pubDate> <item> <title>Boland 25/3 * v KwaZulu-Natal 264/10 </title> <link>http://www.cricinfo.com/ci/engine/match/1123494.html?CMP=OTC-RSS </link> <description>Boland 25/3 * v KwaZulu-Natal 264/10 </description> <guid>http://www.cricinfo.com/ci/engine/match/1123494.html</guid> </item> <item> <title>North West 205/10 v Easterns 123/3 *</title> <link>http://www.cricinfo.com/ci/engine/match/1123495.html?CMP=OTC-RSS </link> <description>North West 205/10 v Easterns 123/3 *</description> <guid>http://www.cricinfo.com/ci/engine/match/1123495.html</guid> </item> <item> <title>Eastern Province 306/6 * v Gauteng</title> <link>http://www.cricinfo.com/ci/engine/match/1123496.html?CMP=OTC-RSS </link> <description>Eastern Province 306/6 * v Gauteng</description> <guid>http://www.cricinfo.com/ci/engine/match/1123496.html</guid> </item> <item> <title>Namibia v Free State 354/8 *</title> <link>http://www.cricinfo.com/ci/engine/match/1123498.html?CMP=OTC-RSS </link> <description>Namibia v Free State 354/8 *</description> <guid>http://www.cricinfo.com/ci/engine/match/1123498.html</guid> </item> <item> <title>South Africa A 220/10 v Australia 87/3 *</title> <link>http://www.cricinfo.com/ci/engine/match/1075981.html?CMP=OTC-RSS </link> <description>South Africa A 220/10 v Australia 87/3 *</description> <guid>http://www.cricinfo.com/ci/engine/match/1075981.html</guid> </item> <item> <title>Guyana 231/10 * v Windward Islands 286/7 </title> <link>http://www.cricinfo.com/ci/engine/match/1134092.html?CMP=OTC-RSS </link> <description>Guyana 231/10 * v Windward Islands 286/7 </description> <guid>http://www.cricinfo.com/ci/engine/match/1134092.html</guid> </item> <item> <title>Karachi Kings v Quetta Gladiators</title> <link>http://www.cricinfo.com/ci/engine/match/1128819.html?CMP=OTC-RSS </link> <description>Karachi Kings v Quetta Gladiators</description> <guid>http://www.cricinfo.com/ci/engine/match/1128819.html</guid> </item> <item> <title>Multan Sultans v Lahore Qalandars</title> <link>http://www.cricinfo.com/ci/engine/match/1128820.html?CMP=OTC-RSS </link> <description>Multan Sultans v Lahore Qalandars</description> <guid>http://www.cricinfo.com/ci/engine/match/1128820.html</guid> </item> </channel> </rss> ENDXML; $rss->SimpleXML_Load_String($xml); $list = array(); $found = 0; foreach ($rss->getElementsByTagName('item') as $node) { $item = array( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue ); array_push($list, $item); } $numberofresults = 20; for ($i = 0; $i < $numberofresults; $i++) { $title = $list[$i]['title']; $titletolower = strtolower($title); $desc = $list[$i]['desc']; $desctolower = strtolower($desc); if (strpos($desctolower, "*") !== false) { $desc = 'Live'; } else { $desc = ' Not Live'; } echo $title . "\n"; echo $desc . "\n"; $found++; } if ($found == 0) { echo $list[$i]['title'][0]; } ?>
based on 232hZ
Output for 7.0.5 - 7.3.0beta1
Notice: Undefined variable: rss in /in/cZi3Z on line 56 Fatal error: Uncaught Error: Call to a member function SimpleXML_Load_String() on null in /in/cZi3Z:56 Stack trace: #0 {main} thrown in /in/cZi3Z on line 56
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: rss in /in/cZi3Z on line 56 Fatal error: Uncaught Error: Call to a member function SimpleXML_Load_String() on unknown in /in/cZi3Z:56 Stack trace: #0 {main} thrown in /in/cZi3Z on line 56
Process exited with code 255.
Output for hhvm-3.22.0
Notice: Undefined variable: rss in /in/cZi3Z on line -1 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function SimpleXML_Load_String() on a non-object (null)' in /in/cZi3Z:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Notice: Undefined variable: rss in /in/cZi3Z on line 56 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function SimpleXML_Load_String() on a non-object (null)' in /in/cZi3Z:56 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Notice: Undefined variable: rss in /in/cZi3Z on line 56 Fatal error: Call to a member function SimpleXML_Load_String() on null in /in/cZi3Z on line 56
Process exited with code 255.