strstr中汉字怎么编码

WBOY
Release: 2016-06-13 10:32:54
Original
828 people have browsed it

strstr中汉字如何编码?
小弟菜鸟,最近写段程序遇到点问题,就是查判断百度来路和搜索关键字

....
$referer=$_SERVER["HTTP_REFERER"];
.....
if(strstr($referer,"baidu")&&strstr($referer,"123"))
{
....
上面的能正常工作,下面这段就不行,因为里面有汉字


....
$referer=$_SERVER["HTTP_REFERER"];
.....
if(strstr($referer,"baidu")&&strstr($referer,"北京"))
{
....
请问如果将其中的汉字如何编码,使之正常工作,谢谢!

------解决方案--------------------
strpos() - 查找字符串首次出现的位置
strrpos() - 计算指定字符串在目标字符串中最后一次出现的位置
strrchr() - 查找指定字符在字符串中的最后一次出现
substr() - 返回字符串的子串
stristr() - strstr 函数的忽略大小写版本
strstr() - 查找字符串的首次出现
strripos() - 计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)
str_ireplace() - str_replace 的忽略大小写版本
------解决方案--------------------
是的.一般都用strpos.

探讨

strpos()函数……速度应该更高效吧!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!