问题描述
我正在使用 stripos函数检查字符串是否位于其中另一个字符串,忽略任何情况.
I am using the stripos function to check if a string is located inside another string, ignoring any cases.
问题出在这里
stripos("ø", "Ø")
返回假.虽然
stripos("Ø", "Ø")
返回true.
如您所见,在这种情况下,该函数看起来 NOT 不区分大小写 .
As you might see, it looks like the function does NOT do a case-insensitive search in this case.
该功能在使用Ææ和Åå等字符时也存在相同的问题.这些是丹麦语字符.
The function has the same problems with characters like Ææ and Åå. These are Danish characters.
推荐答案
请改用 mb_stripos()
.它支持字符集,可以处理多字节字符集. stripos()是过去的美好时光,当时只有ASCII并且所有字符仅为1个字节.
Use mb_stripos()
instead. It's character set aware and will handle multi-byte character sets. stripos() is a holdover from the good old days when there was only ASCII and all chars were only 1 byte.
这篇关于使用特殊字符时,stripos返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!