strpos() 搜索带有 'ç' 的字符串时出现问题
有人可以帮我解决这个问题吗?
我使用 file_get_contents() 从文件中获取所有文本,
该文件上有单词 Reparaç
strpos() 无法找到Reparaç
问题出在 ç
如果我寻找 Repara 它会找到它,所以如果我回显 file_get_contents() 则 > 的 ç 会正常显示
如果我将 file_get_contents() 信息写入另一个文件,
,会出现一个奇怪的符号,而不是我真的厌倦了的 ç并四处搜索尝试解决这个问题,这对于习惯编写 php 代码的人来说可能很容易处理,但顺便说
一句,在我看到的许多网站中, 我无法弄清楚这有什么问题看来该字符集可能与此类问题,我正在使用 UTF-8
can someone help me with this problem?
I've used file_get_contents() to get all text from a file
the file has the word Reparaç on it
strpos() is unable to find Reparaç
if i look for Repara it finds it so the problem is with the ç
if i echo the file_get_contents() the ç appears normally
if i write the file_get_contents() information to another file a strange symbol appears instead of the ç
i'm really tired of doing stuff and searching around to try to fix this and it's probably something easy that people that are used to do php code are pretty used to dealing with but i can't figure out what's wrong with this
by the way, in many websites that i saw it seemed that the charset could be relevant for problems of this kind, i'm using UTF-8
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
mb_strpos()
Try to use
mb_strpos()
使用
mb_strpos()
代替,它是多字节感知的 - strpos 适用于老式 ASCII,并且将对 Unicode 字符串感到厌烦。Use
mb_strpos()
instead, which is multibyte aware - strpos is for oldschool ASCII and will barf on Unicode strings.