Home Backend Development PHP Tutorial strstr中汉字怎么编码

strstr中汉字怎么编码

Jun 13, 2016 pm 01:21 PM
amp quot referer strpos

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()函数……速度应该更高效吧!
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set up Referer in Nginx to prevent image theft How to set up Referer in Nginx to prevent image theft May 12, 2023 pm 06:52 PM

If the server's pictures are hotlinked by other websites, it will affect the server's bandwidth and access speed. At this time, we need to set the anti-hotlink function of the image file or video file; the anti-hotlink function simply means that you can directly access the resource. , but you cannot put my resource links on your own server for others to access, especially large files such as pictures or videos, which can easily cause the server to respond slowly. If it were not a picture host, I would really be afraid that other websites would directly use the pictures from this site. This kind of traffic is likely to be wiped out all at once. After all, CDNs are bought with free money. Therefore, it is better to set up an anti-hot link, nginx can complete this function. Generally speaking, browsers that comply with the http protocol will access the website from a website.

PHP+Referer realizes image hotlink prevention! (Attached with example code) PHP+Referer realizes image hotlink prevention! (Attached with example code) Nov 21, 2022 pm 05:25 PM

This article will introduce to you the issues related to anti-hotlinking in PHP. The main content is to explain the Referer principle and the implementation method of image anti-hotlinking. I hope it will be helpful to friends in need~

What coin is AMP? What coin is AMP? Feb 24, 2024 pm 09:16 PM

What is AMP Coin? The AMP token was created by the Synereo team in 2015 as the main trading currency of the Synereo platform. AMP token aims to provide users with a better digital economic experience through multiple functions and uses. Purpose of AMP Token The AMP Token has multiple roles and functions in the Synereo platform. First, as part of the platform’s cryptocurrency reward system, users are able to earn AMP rewards by sharing and promoting content, a mechanism that encourages users to participate more actively in the platform’s activities. AMP tokens can also be used to promote and distribute content on the Synereo platform. Users can increase the visibility of their content on the platform by using AMP tokens to attract more viewers to view and share

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Find the position of another string in a string using PHP function 'strpos' Find the position of another string in a string using PHP function 'strpos' Jul 26, 2023 pm 12:29 PM

Use the PHP function "strpos" to find the position of another string in a string. In PHP, we often need to find the position of another string in a string. This is very common when working with text, search and replace, etc. PHP provides many string processing functions, one of which is very useful function "strpos", which can help us quickly find the position of the target string in the source string. The following is a simple code example that demonstrates how to use the "strpos" function to query

How to use strpos function in PHP to find words in a string How to use strpos function in PHP to find words in a string Jun 26, 2023 pm 02:39 PM

In PHP, it is often necessary to find words and keywords in strings for processing and analysis. To find words in a string, you can use PHP's built-in strpos function. The strpos function (stringposition) is a built-in function in PHP for finding strings. It is used to find the position of the first occurrence of a specified substring in a string. The format of this function is: strpos($haystack,$needle,[$off

Detailed explanation on the use of strchr, str_replace and strpos functions Detailed explanation on the use of strchr, str_replace and strpos functions Jun 16, 2023 am 08:41 AM

In PHP programming, string processing is relatively common, and operations such as searching and replacing strings are often required. In string processing, it is more common to use strchr, str_replace, and strpos functions. Next, let’s explain the use of these three functions in detail. 1. strchr function The strchr function searches for the specified character in a string and returns the string from the specified character to the end of the string. The syntax is as follows: strchr(string,char

Find the position of another string in a string using PHP function 'strpos' Find the position of another string in a string using PHP function 'strpos' Jul 26, 2023 am 11:29 AM

Find the location of another string in a string using PHP function "strpos" When developing web applications, it is often necessary to find a specific substring within a string. PHP has many useful built-in functions for processing strings, one of which is the "strpos" function. This function can be used to find the position of a string within another string. Here is sample code that uses the "strpos" function to find the position of a substring: <?php$str=&q

See all articles