3v4l.org

run code in 300+ PHP versions simultaneously
<?php function writeXML( $xml, $data ) { foreach( $data as $key => $value ) { if ( preg_match('/^(.*) (.*)=(.*)$/', $key, $matches) != false ) { $xml->startElement( $matches[1] ); $xml->writeAttribute( $matches[2], $matches[3]); if( is_array( $value )) { writeXML( $xml, $value ); $xml->endElement( ); continue; } $xml->text( $value ); $xml->endElement( ); } else { if( is_array( $value )) { $xml->startElement( $key ); writeXML( $xml, $value ); $xml->endElement( ); continue; } echo $key. "\n"; $xml->writeElement( $key, $value ); } } } $name = 'item'; $xml = new XmlWriter(); $xml->openMemory(); $xml->startDocument( '1.0', 'utf-8' ); $xml->startElement( $name ); $data = array( "episodeTitle" => 'test', "episodeDescription" => 'test', "pubDate" => 'test', "imdbid" => 'test', "MediaType" => "TV", "seasonNumber" => 1, "episodeNumber" => 1, "episodeImage" => array ( "url" => 'test', ), "duration" => 'test', "episodeKeywords" => "", "episodePopularity scale=" => 5, "VideoType" => "Episode", "country" => "United States", "language" => "en-us", "geoRestrictions" => 'test', //"dateAvailable" => $start_date, //"expDate" =>$end_date, "category" => 'test', "sourceID" => 'test', "streamType" => "SD", //TODO: multiple formats? "iOSAllowed" => 1, "subscription" => "yes", "price" => 0.00, "videoURL" => 'test', "showtitle" => 'test', "link" => "http://www.flixfling.com/movies/", "showdescription" => 'test', "showLogo" => array ( "url" => 'test', ), "showsourceID" => 'test', "showPubDate" => 'test', "showImdbid>" => 'test', "showCategory" => 'test', "showKeywords" => "", ); writeXML( $xml, $data);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
episodeTitle episodeDescription pubDate imdbid MediaType seasonNumber episodeNumber url duration episodeKeywords VideoType country language geoRestrictions category sourceID streamType iOSAllowed subscription price videoURL showtitle link showdescription url showsourceID showPubDate showImdbid> Fatal error: Uncaught ValueError: XMLWriter::writeElement(): Argument #2 ($content) must be a valid element name, "showImdbid>" given in /in/UnUgG:23 Stack trace: #0 /in/UnUgG(23): XMLWriter->writeElement('showImdbid>', 'test') #1 /in/UnUgG(72): writeXML(Object(XMLWriter), Array) #2 {main} thrown in /in/UnUgG on line 23
Process exited with code 255.
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 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
episodeTitle episodeDescription pubDate imdbid MediaType seasonNumber episodeNumber url duration episodeKeywords VideoType country language geoRestrictions category sourceID streamType iOSAllowed subscription price videoURL showtitle link showdescription url showsourceID showPubDate showImdbid> Warning: XMLWriter::writeElement(): Invalid Element Name in /in/UnUgG on line 23 showCategory showKeywords
Output for 5.1.2 - 5.1.6
episodeTitle episodeDescription pubDate imdbid MediaType seasonNumber episodeNumber url duration episodeKeywords VideoType country language geoRestrictions category sourceID streamType iOSAllowed subscription price videoURL showtitle link showdescription url showsourceID showPubDate showImdbid> Warning: XMLWriter::writeElement(): "Invalid Element Name" in /in/UnUgG on line 23 showCategory showKeywords
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
Fatal error: Class 'XmlWriter' not found in /in/UnUgG on line 29
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: xmlwriter in /in/UnUgG on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: xmlwriter in /in/UnUgG on line 29

preferences:
212.43 ms | 414 KiB | 5 Q