3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_contains_old(string $hay, string $needle): bool { return mb_stripos($hay, $needle) !== false; } $str1 = 'Hello world!'; $str2 = 'hello'; var_dump(str_contains_old($str1, $str2)); // gives bool(true) // str_contains var_dump(str_contains($str1, $str2)); // gives bool(false) $str1 = 'Część'; $str2 = 'cZĘŚĆ'; var_dump(str_contains_old($str1, $str2)); // gives bool(true) // str_contains var_dump(str_contains($str1, $str2)); // gives bool(false) $str1 = 'Część'; $str2 = 'czesc'; var_dump(str_contains_old($str1, $str2)); // gives bool(false) // str_contains var_dump(str_contains($str1, $str2)); // gives bool(false)
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
bool(true) bool(false) bool(true) bool(false) bool(false) bool(false)
Output for 7.4.0 - 7.4.33
bool(true) Fatal error: Uncaught Error: Call to undefined function str_contains() in /in/lprsk:12 Stack trace: #0 {main} thrown in /in/lprsk on line 12
Process exited with code 255.

preferences:
72.42 ms | 407 KiB | 5 Q