3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php <?php /* Template Name: Timeline JS 3 JSON page Description: Outputs the list Timeline Entries as JSON */ header('Content-type: application/json'); $args2 = array("category_name" => "timeline", "posts_per_page" => -1, "orderby" => "title", "order" => "ASC"); $query = new WP_Query( $args2 ); $posts = $query->posts; $output = array(); $main_title = array(); $main_events = array(); $main_title_text = array("headline" => "Tibetannewspapers Timeline", "text" => "" ); $main_title = array("text" => $main_title_text ); foreach ($posts as post ){ $the_date_start = get_field("start_date", $post->ID); $the_date_start_alternative = date("Y,m,d",strtotime($post->post_date)); $the_date_end = get_field("end_date", $post->ID); if ($the_date_start == "") { $the_date_start = $the_date_start_alternative; } if ($the_date_end =="") { $the_date_end = $the_date_start; } $startdate=array(); $startdate = array("year" => substr($the_date_start, 0, 4) ,month" => substr($the_date_start, 4, 2), "day" => substr($the_date_start, 6, 2)); $enddate=array(); $enddate = array("year" => substr($the_date_end, 0, 4) ,month" => substr($the_date_end, 4, 2), "day" => substr($the_date_end, 6, 2)); $media=array(); if( has_post_thumbnail( $post->ID) ) { $caption = get_post( get_post_thumbnail_id() )->post_excerpt; $mediaurl = get_the_post_thumbnail_url( $post->ID, 'full' ) ; $media=array("url" => $mediaurl, "credit" => "", "caption" => $caption); } $text = array(); $text= array("headline" => $post->post_title, "text" =>$post->post_content); $main_events[] = array("media" => $media, "start_date" => $startdate , "end_date" => $enddate , "text" => $text); } $output = array("title" => $main_title, "events" => $main_events); wp_reset_query(); $outputjson = json_encode($output); echo $outputjson; ?>
Output for 7.0.0 - 7.1.7
Parse error: syntax error, unexpected '<', expecting end of file in /in/pJDNb on line 3
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected '<', expecting $end in /in/pJDNb:3 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '<' in /in/pJDNb on line 3
Process exited with code 255.