Home Backend Development PHP Tutorial urlencode的有关问题奇怪了

urlencode的有关问题奇怪了

Jun 13, 2016 pm 01:16 PM
str string url urlencode

urlencode的问题奇怪了,请教大家
我想把字符串“('baidu')中”用php的urlencode函数输出这样的字符串:('baidu')%e4%b8%ad

但实际上输出:%28%27baidu%27%29,

我在百度搜索关键字:在线url编码,结果排名第三的是:百度应用的一个url编码小程序,在那个用utf8编码就可以输出:

('baidu')%e4%b8%ad,请问为什么啊?

当然字符串当中汉字“中”,生成的不一样无所谓,因为我的源代码是utf8,的,所以,但是我就奇怪了怎么才能让php
的urlencode()函数,不编码逗号和小括号呢?


------解决方案--------------------
string urlencode ( string $str )
返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。

百度那个并不严格,如果你不希望转码括号,可以对转码后的结果用 str_replace('%28', '(', $enstr) 替换过来

------解决方案--------------------
百度那个就是不准,我用过.

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 Article Tags

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)

Convert basic data types to strings using Java's String.valueOf() function Convert basic data types to strings using Java's String.valueOf() function Jul 24, 2023 pm 07:55 PM

Convert basic data types to strings using Java's String.valueOf() function

PHP function introduction—get_headers(): Get the response header information of the URL PHP function introduction—get_headers(): Get the response header information of the URL Jul 25, 2023 am 09:05 AM

PHP function introduction—get_headers(): Get the response header information of the URL

How to convert char array to string How to convert char array to string Jun 09, 2023 am 10:04 AM

How to convert char array to string

Why NameResolutionError(self.host, self, e) from e and how to solve it Why NameResolutionError(self.host, self, e) from e and how to solve it Mar 01, 2024 pm 01:20 PM

Why NameResolutionError(self.host, self, e) from e and how to solve it

How to get your Steam ID in a few steps? How to get your Steam ID in a few steps? May 08, 2023 pm 11:43 PM

How to get your Steam ID in a few steps?

How to use URL encoding and decoding in Java How to use URL encoding and decoding in Java May 08, 2023 pm 05:46 PM

How to use URL encoding and decoding in Java

Use Java's String.replace() function to replace characters (strings) in a string Use Java's String.replace() function to replace characters (strings) in a string Jul 25, 2023 pm 05:16 PM

Use Java's String.replace() function to replace characters (strings) in a string

2w words detailed explanation String, yyds 2w words detailed explanation String, yyds Aug 24, 2023 pm 03:56 PM

2w words detailed explanation String, yyds

See all articles