3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo '<p>[PHP VERSION: '.phpversion().']</p>'; $state = 'foo'; toggle($state); echo $state; // in php 7.0.5 : still foo! function toggle(&$state) { switch ($state) { case 'foo': $state = 'bar'; break; case 'bar': $state = 'foo'; break; } }
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.4, 7.0.6 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.24, 8.4.1 - 8.4.11
<p>[PHP VERSION: 8.4.11]</p>bar
Output for 7.0.5
<p>[PHP VERSION: 7.0.5]</p>foo

preferences:
58.07 ms | 2051 KiB | 4 Q