3v4l.org

run code in 300+ PHP versions simultaneously
<?php function display_post( $postdata ) { echo "<div class='post'>"; echo "<h1>" . $postdata['post_title'] . "</h1>"; echo "<p>" . $postdata['post_excerpt'] . "</p>"; echo "<div class='post-meta'>Published on " . $postdata['post_date'] . " by " . $postdata['post_author'] . "</div>"; echo "</div>"; } $posts = array( 0 => array( "post_title" => "My First Post", "post_excerpt" => "This is a short snippet of text from the first post", "post_date" => "2015 December 1", "post_author" => "Daniel Pataki" ), 1 => array( "post_title" => "Second Post", "post_excerpt" => "Short exceprt for post number 2", "post_date" => "2015 December 4", "post_author" => "Raelene Morey" ) ); foreach( $posts as $post ) { display_post( $post ); }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
<div class='post'><h1>My First Post</h1><p>This is a short snippet of text from the first post</p><div class='post-meta'>Published on 2015 December 1 by Daniel Pataki</div></div><div class='post'><h1>Second Post</h1><p>Short exceprt for post number 2</p><div class='post-meta'>Published on 2015 December 4 by Raelene Morey</div></div>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <div class='post'><h1>My First Post</h1><p>This is a short snippet of text from the first post</p><div class='post-meta'>Published on 2015 December 1 by Daniel Pataki</div></div><div class='post'><h1>Second Post</h1><p>Short exceprt for post number 2</p><div class='post-meta'>Published on 2015 December 4 by Raelene Morey</div></div>

preferences:
176.73 ms | 402 KiB | 172 Q