PHP custom urlencode, urldecode function example_PHP tutorial

WBOY
Release: 2016-07-13 10:00:48
Original
1231 people have browsed it

php custom urlencode, urldecode function examples

This article mainly introduces php custom urlencode, urldecode function, and examples analyze the techniques of php string transcoding, which has certain For reference value, friends in need can refer to it

The example in this article describes PHP’s custom urlencode and urldecode functions. Share it with everyone for your reference. The details are as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

//配合JavaScript的ajaxObject函数, 对字串进行转码.

function ajax_encode($str){

$patern = array("/%/","/=/","/&/");

// % 必须是第一个项, 替换是按项的顺序进行的.

$rp = array("%","&","=");

return preg_replace($patern,$rp,$str);

}

//逆函数

function ajax_decode($str){

$patern = array("/%/","/&/","/=/");

$rp = array("%","=","&");

return preg_replace($patern,$rp,$str);

}

1 2

3

4 5

67 8 9 10 11 12
13
//Cooperate with JavaScript’s ajaxObject function to transcode the string. function ajax_encode($str){ $patern = array("/%/","/=/","/&/"); // % must be the first item, replacement is performed in the order of items. $rp = array("%","&","="); return preg_replace($patern,$rp,$str); } //Inverse function function ajax_decode($str){ $patern = array("/%/","/&/","/=/"); $rp = array("%","=","&"); return preg_replace($patern,$rp,$str); }
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/973117.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/973117.htmlTechArticlephp custom urlencode, urldecode function example This article mainly introduces php custom urlencode, urldecode function, example analysis Learned the skills of php string transcoding, and it has certain reference value...
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