3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(range([], [])); echo "Range will ignore any byte after the first one\n"; var_dump( range("AA", "BB") ); echo "Range cannot operate on an empty string\n"; var_dump( range("Z", "") ); // Both strings are cast to int, i.e. 0 var_dump( range("", "Z") ); // Both strings are cast to int, i.e. 0 echo "Mixing numeric string and character\n"; var_dump( range("1", "A") ); // The char is cast to an int, i.e. 0 var_dump( range("?", "1") ); // The char is cast to an int, i.e. 0 var_dump( range("3.5", "A") ); // The char is cast to a float, i.e. 0 var_dump( range("?", "3.5") ); // The char is cast to a float, i.e. 0 echo "Fractional step cannot be used on character ranges\n"; var_dump( range("A", "H", 2.6) ); // Because step is fractional it tries to interpret inputs as floats
Output for 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
Fatal error: Uncaught TypeError: range(): Argument #1 ($start) must be of type string|int|float, array given in /in/XqeoP:3 Stack trace: #0 /in/XqeoP(3): range(Array, Array) #1 {main} thrown in /in/XqeoP on line 3
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 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29
array(1) { [0]=> int(0) } Range will ignore any byte after the first one array(2) { [0]=> string(1) "A" [1]=> string(1) "B" } Range cannot operate on an empty string array(1) { [0]=> int(0) } array(1) { [0]=> int(0) } Mixing numeric string and character array(2) { [0]=> int(1) [1]=> int(0) } array(2) { [0]=> int(0) [1]=> int(1) } array(4) { [0]=> float(3.5) [1]=> float(2.5) [2]=> float(1.5) [3]=> float(0.5) } array(4) { [0]=> float(0) [1]=> float(1) [2]=> float(2) [3]=> float(3) } Fractional step cannot be used on character ranges array(1) { [0]=> float(0) }

preferences:
56.3 ms | 411 KiB | 5 Q