@ 2022-05-06T14:03:32Z <?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)
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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:dark mode live preview
72.42 ms | 407 KiB | 5 Q