温馨提示×

stripos能否忽略大小写检索

小樊
81
2024-06-28 19:43:27
栏目: 编程语言

是的,stripos函数可以忽略大小写进行检索。可以在函数的第三个参数中传入常量值STR_CASE_INSENSITIVE来实现忽略大小写的检索。示例代码如下:

$string = 'Hello, World!';
$pos = stripos($string, 'hello', 0, STR_CASE_INSENSITIVE);
if ($pos !== false) {
    echo 'The word "hello" is found in the string.';
} else {
    echo 'The word "hello" is not found in the string.';
}

0