3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ 'false' => false, 'true' => true, 'null' => null, '0' => 0, '0.1' => 0.1, 'a' => 'a', '[\'foo\']' => ['foo'], '(object) [\'bar\', \'bar\']' => (object) ['bar', 'bar'], ]; echo "<table border=1>"; echo '<tr><th>input</th><th>echo</th><th>printf</th><th>print_r</th><th>var_export</th><th>var_dump</th></tr>'; foreach ($tests as $input => $test) { echo "<tr>"; echo "<th>$input</th><td>"; echo is_array($test) || is_object($test) ? json_encode($test) : $test; echo "</td><td>"; printf('%s', is_array($test) || is_object($test) ? json_encode($test) : $test); echo "</td><td>"; print_r($test); echo "</td><td>"; var_export($test); echo "</td><td>"; var_dump($test); echo "</td></tr>"; } echo "</table>";

preferences:
24.06 ms | 408 KiB | 5 Q