Home Backend Development PHP Tutorial URL接收的参数乱码,但是当地是正常的

URL接收的参数乱码,但是当地是正常的

Jun 13, 2016 am 10:52 AM
localhost quot search urlencode

URL接收的参数乱码,但是本地是正常的
http://localhost/xs7k/search/author-龙.html 就是正常的
这里有URL重写对应的为xs7k/search/index.php?type=$1&key=$2
本地获取key就是正常的,以前用bluehost的主要也是正常的

服务器上就不行了http://www.xs7k.com/search/author-龙.html,如这个。

今天换成国内的了iis的,能数只要是中文的就出错"??"显示成这个样子,请问有没有什么办法解决。

用$_REQUEST或$_GET都一样的。

------解决方案--------------------
$url="http://localhost/xs7k/search/".UrlEnCode('author-龙').".html";
先把中文编码一下再传$url这个变量试试.
如果urlencode这个编码不行的话你就用Base64_Encode编码,,不过用Base64_Encode的话需要用对应的解码函数解码一下才行.UrlEnCode就没有那么麻烦了.
------解决方案--------------------
不同浏览器传输中文的时候,字符集不同。有GBK的,也有UTF-8的。用urlencode一下,会比较妥当。
------解决方案--------------------
补充,我说的是在地址栏传输中文。
------解决方案--------------------
还是1楼的方法,你就直接取值的时候取转换完的值,比如php:alt="urlencode('龙')"JS:attr(alt)
------解决方案--------------------

探讨
我的这一句是从JS转过去的http://localhost/xs7k/search/author-龙.html

location.href='../search/'+type.options[type.selectedIndex].value+'-'+key.value+'.html';

在这里如果对key.value进行编码,PHP的不能用在这里的吧?
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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
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)

Why can't mysql connect to localhost? Why can't mysql connect to localhost? Aug 10, 2023 pm 02:55 PM

The reasons why mysql cannot connect to localhost are that the mysql service is not started, the mysql port is occupied, and there is a problem with the MySQL configuration file. Detailed introduction: 1. In Windows systems, you can open the service manager by entering "services.msc" at the command prompt, then find the mysql service and ensure that its status is "Running". In Linux systems, you can use the "services.msc" command to check and control the service status; 2. You can use the open command and so on.

What should I do if localhost cannot be opened? What should I do if localhost cannot be opened? Nov 07, 2023 pm 02:47 PM

Solution: 1. Check the running status of the server and make sure it is listening on the correct port; 2. Try to temporarily disable the firewall or security software, and then try to access localhost again; 3. Check the hosts file of the operating system to ensure that localhost is resolved correctly ; 4. Try to restart the network adapter or reconfigure the network connection; 5. Try to change the port used by the local server, or close other programs that occupy the same port; 6. Try to manually add the corresponding IP address and domain name in the hosts file, etc.

What does linux localhost mean? What does linux localhost mean? Mar 14, 2023 am 09:53 AM

linux localhost means "computer host name". The host name is used to identify an independent computer on the network; the root in "root@localhost" represents the currently logged-in user. In Linux, the administrator account is root, and the user is root. Log in to the Linux machine as a user.

PHP's urlencode() function: How to encode a string into a URL-safe format PHP's urlencode() function: How to encode a string into a URL-safe format Nov 03, 2023 pm 12:39 PM

PHP's urlencode() function: How to encode a string into a URL-safe format, specific code examples are needed. With the development of the Internet, URLs are widely used in daily life, and we often need to encode strings with some special characters into URL-safe formats. Format to pass parameters in the URL or request a web page. PHP provides the urlencode() function to accomplish this task. This article will introduce the usage of urlencode() function and give some specific code examples. 1. ur

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

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

How to use urlencode function to encode URL in PHP How to use urlencode function to encode URL in PHP Jun 26, 2023 pm 12:48 PM

In modern development, passing data through URLs is a common way. However, because the URL may contain some special characters, such as spaces, slashes, and question marks, these special characters will destroy the structure of the URL and cause data transmission to fail. In order to avoid this situation, PHP provides the urlencode function, which can encode the URL into a transportable format. The use of the urlencode function is very simple. Its syntax is as follows: stringurlencode(string

Introduction to PHP functions—urlencode(): encode URLs Introduction to PHP functions—urlencode(): encode URLs Jul 25, 2023 pm 09:25 PM

Introduction to PHP functions—urlencode(): Encoding URLs When developing web applications, you often encounter situations where URLs need to be encoded. URL encoding ensures that special characters in URLs are passed correctly, avoiding problems or incorrect results. In PHP, we can use the urlencode() function to perform URL encoding. The function of urlencode() function is to convert the string into an encoding format that conforms to the URL specification. It converts non-alphanumeric characters in a string to

The Browser Company launches Arc Search: AI-assisted, upgraded search experience The Browser Company launches Arc Search: AI-assisted, upgraded search experience Feb 01, 2024 am 09:18 AM

According to news on January 31, TheBrowserCompany recently released a new application called ArcSearch, which makes full use of AI technology and aims to help users obtain the information they need more quickly and conveniently. The core feature of the ArcSearch application is its "Browseforme" function, which is powered by models from companies such as OpenAI. When a user searches, this function can automatically read at least six related web pages, integrate and summarize this information through AI technology, and finally display it to the user on a newly designed page. This page not only contains information related to the search keywords, but also divides the content into different parts to make it clearer for users.

See all articles