3v4l.org

run code in 300+ PHP versions simultaneously
<?php $float = 1.223; $float2 = 789.012; $prefix = ' World67'; echo round($float, 2). ' Hello ' . (int) $float . substr($prefix, 0, 6) . substr($prefix, 0, 6); echo \PHP_EOL; echo round($float2, 2). ' Hello ' . (int) $float2 . substr($prefix, 0, 6) . substr($prefix, 0, 6); echo \PHP_EOL . '---' . \PHP_EOL; $pattern = '%1$.2f Hello %1$.d %2$.6s'; printf($pattern, $float, $prefix); echo \PHP_EOL; printf($pattern, $float2, $prefix); echo \PHP_EOL; //purposefully error printf($pattern, $prefix);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
1.22 Hello 1 World World 789.01 Hello 789 World World --- 1.22 Hello 1 World 789.01 Hello 789 World Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given in /in/8PWil:16 Stack trace: #0 /in/8PWil(16): printf('%1$.2f Hello %1...', ' World67') #1 {main} thrown in /in/8PWil on line 16
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
1.22 Hello 1 World World 789.01 Hello 789 World World --- 1.22 Hello 1 World 789.01 Hello 789 World Warning: printf(): Too few arguments in /in/8PWil on line 16

preferences:
167.13 ms | 410 KiB | 5 Q