PHP urledcode 在JS里的转换
来源:互联网 发布:ubuntu 16 共享文件夹 编辑:程序博客网 时间:2024/05/28 03:03
一些数据在PHP里用urledcode了,传到前端,需要把数据转换,不然有些特殊的字符会以%开始的转换字符,JS decodeURIComponent 函数可以转换。
Decodes URL-encoded string
function urldecode (str) { // Decodes URL-encoded string // // version: 1109.2015 // discuss at: http://phpjs.org/functions/urldecode // + original by: Philip Peterson // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + input by: AJ // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: travc // + input by: Brett Zamir (http://brett-zamir.me) // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Lars Fischer // + input by: Ratheous // + improved by: Orlando // + reimplemented by: Brett Zamir (http://brett-zamir.me) // + bugfixed by: Rob // + input by: e-mike // + improved by: Brett Zamir (http://brett-zamir.me) // % note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/ // % note 2: Please be aware that this function expects to decode from UTF-8 encoded strings, as found on // % note 2: pages served as UTF-8 // * example 1: urldecode('Kevin+van+Zonneveld%21'); // * returns 1: 'Kevin van Zonneveld!' // * example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F'); // * returns 2: 'http://kevin.vanzonneveld.net/' // * example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'); // * returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a' return decodeURIComponent((str + '').replace(/\+/g, '%20')); }
详细可以看 下面这编文章:http://phpjs.org/functions/urldecode:572
- PHP urledcode 在JS里的转换
- PHP 数组转JSON对象 然后在js 里输出
- 在IIS里安装PHP的方法
- 在IIS里安装PHP的方法
- PHP在Flex3里的交互
- 正则表达式在PHP里的应用
- 在js里的路径问题
- map在js里的遍历
- 引号在HTML里和JS里的嵌套
- 在iframe里调用主页面里的js函数
- js放在head里和body里的差别
- js放在<head>里 和 <body>里的区别
- 在js里怎么实现Xcode里的callFuncN
- $在php里
- php和js的json转换
- C#里HttpUtility.UrlEncode和JS端转换的心得
- 在PHP里Cookie的使用是有一些限制的。
- window.location.href妙用 标签里用js 利用这个简单的转换思路 实现 一直也无法实现的在 页面的html标签使
- SAP alv 去掉标准按钮
- iOS开发视频教程下载/iphone开发视频教程下载
- su - root 和 su root 的区别
- Linux基础命令之Test
- 对于C#学习的困扰
- PHP urledcode 在JS里的转换
- VB.NET开发人员必备参考书
- 请读者帮忙投个票喔
- TAP---资料整合----Good Luck!
- ss7七号信令简介
- MFC中的类使用注意
- 32位数中有多少个 1
- 23种设计模式的形象比喻
- 不使用第三个变量,交换两个变量的值!