3v4l.org

run code in 500+ PHP versions simultaneously
<?php use function PHPStan\dumpType; use function PHPStan\Testing\assertType; function doFoo(string $namespace):void { if (substr($namespace, 0, 4) === 'hello-world') {var_dump(__LINE__);} if ('hello-world' === substr($namespace, 0, 4)) {var_dump(__LINE__);} if (substr($namespace, 0, 13) === 'hello-world') {var_dump(__LINE__);} if ('hello-world' === substr($namespace, 0, 13)) {var_dump(__LINE__);} if (substr($namespace, 0, 11) === 'hello-world') {var_dump(__LINE__);} if ('hello-world' === substr($namespace, 0, 11)) {var_dump(__LINE__);} } doFoo('hello-world'); var_dump('--'); doFoo('abc'); var_dump('--'); doFoo('hello-world-in-php');
Output for 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
int(10) int(11) int(13) int(14) string(2) "--" string(2) "--" int(13) int(14)

preferences:
28.01 ms | 1136 KiB | 7 Q