PHP:第五章——字符串编码函数
<?php
header("Content-Type:text/html;charset=utf-8");
//1.base64_encode和base64_decode。64位编码转换。
/*$str='美丽中国';
echo base64_encode($str);
//输出:576O5Li95Lit5Zu9
echo base64_decode('576O5Li95Lit5Zu9 ');*/
//输出:美丽中国 //2.http_build_query 生成URL_encode请求字符串。
/*$str=array('z'=>'zhong','g'=>'guo','age'=>108);
echo http_build_query($str);*/
//输出:z=zhong&g=guo&age=108 //3.parse_url解析url字符串。
/*$url="http://www.phpdl.com/index.php?site=PHP中国&school=DongLi#abc";
print_r(parse_url($url));*/
//输出:Array ( [scheme] => http [host] => www.phpdl.com [path] => /index.php [query] => site=PHP中国&school=DongLi [fragment] => abc ) //4.urlencode编码url字符。
/*$url="http://www.baidu.com";
echo urlencode($url);*/
//输出:http%3A%2F%2Fwww.baidu.com //5.urldecode解码已编码的url字符串。
/*$url="http%3A%2F%2Fwww.baidu.com";
echo urldecode($url);*/
//输出:http://www.baidu.com //6.rawurlencode 按照 RFC 1738 对 URL 进行编码
/*$str="http://www.baidu.com";
echo rawurlencode($str);*/
//输出:http%3A%2F%2Fwww.baidu.com //7.rawurldecode 对已编码的 URL 字符串进行解码
echo rawurldecode('http%3A%2F%2Fwww.baidu.com ');
//输出:http://www.baidu.com
?>
PHP:第五章——字符串编码函数的更多相关文章
- PHP:第五章——字符串过滤函数
<?php header("Content-Type:text/html;charset=utf-8"); //字符串过滤函数: //1.n12br 在所有新行之前插入Htm ...
- 15第十五章UDF用户自定义函数(转载)
15第十五章UDF用户自定义函数 待补上 原文链接 本文由豆约翰博客备份专家远程一键发布
- JS 字符串编码函数(解决URL特殊字符传递问题):escape()、encodeURI()、encodeURIComponent()区别详解
javaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- JavaScript 字符串编码函数
JavaScript中有三个可以对字符串编码的函数,分别是: escape,encodeURI,encodeURIComponent,相应3个解码函数:unescape,decodeURI,decod ...
- PHP:第五章——字符串与数组及其他函数
<?php header("Content-Type:text/html;charset=utf-8"); //1.str_split——将字符串转换为数组. /*$str= ...
- PHP:第五章——字符串加密及校验函数
<?php header("Content-Type:text/html;charset=utf-8"); //1.md5——计算字符中的散列值 //对一段信息(Messag ...
- php自动获取字符串编码函数mb_detect_encoding(转)
使用 mb_detect_encoding() 函数来判断字符串是什么编码的. 当在php中使用mb_detect_encoding函数进行编码识别时,很多人都碰到过识别编码有误的问题,例如对与GB2 ...
- PHP:第五章——字符串的统计及查找
<?php header("Content-Type:text/html;charset=utf-8"); /*字符串的统计与查找*/ //1.获取字符串的长度 //1)st ...
- php自动获取字符串编码函数mb_detect_encoding
当在php中使用mb_detect_encoding函数进行编码识别时,很多人都碰到过识别编码有误的问题,例如对与GB2312和UTF- 8,或者UTF-8和GBK(这里主要是对于cp936的判断), ...
随机推荐
- flask的session用法2
from flask import Flask, session, redirect, url_for, escape, request app = Flask(__name__) @app.rout ...
- 用 chown 和 chmod 修改目录所属用户及权限
1.修改 tmp 目录所属用户为 root,用户组为 root chown -R root:root /tmp12.修改 tmp 目录为可写权限 chmod -R 777 /tmp
- day17(JDBC入门&jdbcUtils工具介绍)
day17 JDBC整体思维导图 JDBC入门 导jar包:驱动! 加载驱动类:Class.forName("类名"); 给出url.username.password,其中url ...
- mysql 表的增删改查
一.表介绍 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,称为表的字段 对于一张表来说,字段是必须要有的. 数据表 类似于excel id,name,qq, ...
- 美图秀秀DBA谈MySQL运维及优化
美图秀秀DBA谈MySQL运维及优化 https://mp.weixin.qq.com/s?__biz=MzI4NTA1MDEwNg==&mid=401797597&idx=2& ...
- java-基础-【四】实际编程中的对象
一.概述 实际编程开发中,仅仅一个数据库对象映射是满足不了各种复杂需求. O/R Mapping 是 Object Relational Mapping(对象关系映射)的缩写.通俗点讲,就是将对象与关 ...
- rails 日期取值
获取当前时间 当前时间 Time.now UTC时间, 国际标准时间 Time.now.utc 日相关 今日开始时间00:00:00 Time.now.beginning_of_day => 2 ...
- active admin常用配置
ActiveAdmin.register Post do permit_params :title, :content, :deadline, :status menu parent: "论 ...
- 89. Gray Code(公式题)
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- Educational Codeforces Round 54 (Rated for Div. 2) Solution
A - Minimizing the String solved 题意:给出一个字符串,可以移掉最多一个字符,在所有可能性中选取一个字典序最小的. 思路:显然,一定可以移掉一个字符,如果移掉的字符的后 ...