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 git.master, git.master_jit, rfc.property-hooks
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.

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:
163.49 ms | 406 KiB | 5 Q