3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Bug report: https://phabricator.wikimedia.org/T250568 // // Source code: // https://gerrit.wikimedia.org/g/mediawiki/core/+/e839aaae0f52bfc03f609776d8493f2d83a79a06/tests/phpunit/includes/ExportTest.php#41 $sink = <<<TEXT <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.11/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.11/ http://www.mediawiki.org/xml/export-0.11.xsd" version="0.11" xml:lang="en"> <siteinfo> <sitename>docker-default</sitename> <dbname>default</dbname> <base>http://default.web.mw.localhost:80/mediawiki/index.php/Main_Page</base> <generator>MediaWiki 1.35.0-alpha</generator> <case>first-letter</case> <namespaces> <namespace key="-2" case="first-letter">Media</namespace> <namespace key="-1" case="first-letter">Special</namespace> <namespace key="0" case="first-letter" /> <namespace key="1" case="first-letter">Talk</namespace> <namespace key="2" case="first-letter">User</namespace> <namespace key="3" case="first-letter">User talk</namespace> <namespace key="4" case="first-letter">Project</namespace> <namespace key="5" case="first-letter">Project talk</namespace> <namespace key="6" case="first-letter">File</namespace> <namespace key="7" case="first-letter">File talk</namespace> <namespace key="8" case="first-letter">MediaWiki</namespace> <namespace key="9" case="first-letter">MediaWiki talk</namespace> <namespace key="10" case="first-letter">Template</namespace> <namespace key="11" case="first-letter">Template talk</namespace> <namespace key="12" case="first-letter">Help</namespace> <namespace key="13" case="first-letter">Help talk</namespace> <namespace key="14" case="first-letter">Category</namespace> <namespace key="15" case="first-letter">Category talk</namespace> <namespace key="2300" case="first-letter">Gadget</namespace> <namespace key="2301" case="first-letter">Gadget talk</namespace> <namespace key="2302" case="case-sensitive">Gadget definition</namespace> <namespace key="2303" case="case-sensitive">Gadget definition talk</namespace> </namespaces> </siteinfo> <page> <title>UTPage</title> <ns>0</ns> <id>1</id> <revision> <id>1</id> <timestamp>2020-04-30T21:38:27Z</timestamp> <contributor> <username>UTSysop</username> <id>1</id> </contributor> <comment>UTPageSummary</comment> <origin>1</origin> <model>wikitext</model> <format>text/x-wiki</format> <text bytes="9" sha1="aqhji8gcje5j0y511s7kgskw3dd6qua" xml:space="preserve">UTContent</text> <sha1>aqhji8gcje5j0y511s7kgskw3dd6qua</sha1> </revision> </page> </mediawiki> TEXT; $xmlObject = simplexml_load_string( $sink ); $xmlNamespaces = (array)$xmlObject->siteinfo->namespaces->namespace; $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces ); unset( $xmlNamespaces[ '@attributes' ] ); foreach ( $xmlNamespaces as &$namespaceObject ) { if ( is_object( $namespaceObject ) ) { $namespaceObject = ''; } } var_dump( $xmlNamespaces );
Output for 8.0.0
Warning: Array to string conversion in /in/HtN9R on line 67 array(22) { [0]=> string(5) "Media" [1]=> string(7) "Special" [2]=> string(0) "" [3]=> string(4) "Talk" [4]=> string(4) "User" [5]=> string(9) "User_talk" [6]=> string(7) "Project" [7]=> string(12) "Project_talk" [8]=> string(4) "File" [9]=> string(9) "File_talk" [10]=> string(9) "MediaWiki" [11]=> string(14) "MediaWiki_talk" [12]=> string(8) "Template" [13]=> string(13) "Template_talk" [14]=> string(4) "Help" [15]=> string(9) "Help_talk" [16]=> string(8) "Category" [17]=> string(13) "Category_talk" [18]=> string(6) "Gadget" [19]=> string(11) "Gadget_talk" [20]=> string(17) "Gadget_definition" [21]=> &string(22) "Gadget_definition_talk" }
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.16, 7.3.18 - 7.3.26, 7.4.0 - 7.4.4, 7.4.6 - 7.4.13
array(22) { [0]=> string(5) "Media" [1]=> string(7) "Special" [2]=> string(0) "" [3]=> string(4) "Talk" [4]=> string(4) "User" [5]=> string(9) "User_talk" [6]=> string(7) "Project" [7]=> string(12) "Project_talk" [8]=> string(4) "File" [9]=> string(9) "File_talk" [10]=> string(9) "MediaWiki" [11]=> string(14) "MediaWiki_talk" [12]=> string(8) "Template" [13]=> string(13) "Template_talk" [14]=> string(4) "Help" [15]=> string(9) "Help_talk" [16]=> string(8) "Category" [17]=> string(13) "Category_talk" [18]=> string(6) "Gadget" [19]=> string(11) "Gadget_talk" [20]=> string(17) "Gadget_definition" [21]=> &string(22) "Gadget_definition_talk" }
Output for 7.3.17, 7.4.5
array(22) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> string(0) "" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" [12]=> string(0) "" [13]=> string(0) "" [14]=> string(0) "" [15]=> string(0) "" [16]=> string(0) "" [17]=> string(0) "" [18]=> string(0) "" [19]=> string(0) "" [20]=> string(0) "" [21]=> &string(0) "" }