3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('str_contains')) { function str_contains(string $haystack, string $needle): bool { return '' === $needle || false !== strpos($haystack, $needle); } }; $types = [ 'string' => 'test', 'int' => 1, 'float' => 1.23, 'null' => null, 'true' => true, 'false' => false, 'object' => new StdClass(), 'array' => [], ]; $result = [ ]; foreach($types as $type => $val) { try { $res = str_contains($val, 'test'); } catch (Error $e) { $res = 'Fatal error triggered'; } $result[$type] = $res; } var_export($result);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/LPetC on line 31 array ( 'string' => true, 'int' => false, 'float' => false, 'null' => false, 'true' => false, 'false' => false, 'object' => 'Fatal error triggered', 'array' => 'Fatal error triggered', )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /in/LPetC on line 31 array ( 'string' => true, 'int' => false, 'float' => false, 'null' => false, 'true' => false, 'false' => false, 'object' => 'Fatal error triggered', 'array' => 'Fatal error triggered', )
Output for 8.0.0 - 8.0.30
array ( 'string' => true, 'int' => false, 'float' => false, 'null' => false, 'true' => false, 'false' => false, 'object' => 'Fatal error triggered', 'array' => 'Fatal error triggered', )
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
array ( 'string' => true, 'int' => false, 'float' => false, 'null' => 'Fatal error triggered', 'true' => false, 'false' => false, 'object' => 'Fatal error triggered', 'array' => 'Fatal error triggered', )

preferences:
166.88 ms | 402 KiB | 181 Q