3v4l.org

run code in 300+ PHP versions simultaneously
<?php function writeXML( $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( $value ); $xml->endElement( ); continue; } $xml->text( $value ); $xml->endElement( ); } else { if( is_array( $value )) { $xml->startElement( $key ); $writeXML( $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( "title" => 'test', "description" => 'test description', "pubDate" => '1999', "imdbid" => "", "MediaType" => "Movie", "moviePoster" => array ( "url" => 'bad&filename.jpg', ), "studio" => 'WB', "officialRating type=mpaa" => 'PG', "duration" => 120 "movieKeywords" => "", "moviePopularity scale=" => 4, "VideoType" => "movie", "country" => "United States", "language" => "en-us", "geoRestrictions" => '', //"dateAvailable" => $start_date, //"expDate" =>$end_date, "showCategory" => 'All', "sourceID" => 2222, "streamType" => "SD", "iOSAllowed" => 0, "subscription" => "no", "price" => 0.00, "videoURL" => "http://www.flixfling.com/movies/2222", ); $writeXML($data);
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected '$data' (T_VARIABLE) in /in/C2JFu on line 33
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/C2JFu on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_VARIABLE in /in/C2JFu on line 33
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/C2JFu on line 33
Process exited with code 255.

preferences:
216.46 ms | 1395 KiB | 125 Q