mb_convert_variables

  • (PHP 4 >= 4.0.6, PHP 5, PHP 7)
  • mb_convert_variables — Convert character code in variable(s)
  • mb_convert_variables — 转换一个或多个变量的字符编码

Description

string mb_convert_variables ( string $to_encoding , mixed $from_encoding , mixed &$vars [, mixed &$... ] )
//Converts character encoding of variables vars in encoding from_encoding to encoding to_encoding.
//将变量 vars 的编码从 from_encoding 转换成编码 to_encoding。
//mb_convert_variables() join strings in Array or Object to detect encoding, since encoding detection tends to fail for short strings. Therefore, it is impossible to mix encoding in single array or object.
//mb_convert_variables() 会拼接变量数组或对象中的字符串来检测编码,因为短字符串的检测往往会失败。因此,不能在一个数组或对象中混合使用编码。

Parameters

to_encoding

  • The encoding that the string is being converted to.
  • 将 string 转换成这个编码。

from_encoding

  • from_encoding is specified as an array or comma separated string, it tries to detect encoding from from-coding. When from_encoding is omitted, detect_order is used.
  • from_encoding 可以指定为一个 array 或者逗号分隔的 string,它将尝试根据 from-coding 来检测编码。 当省略了 from_encoding,将使用 detect_order。

vars

  • vars is the reference to the variable being converted. String, Array and Object are accepted. mb_convert_variables() assumes all parameters have the same encoding.
  • vars 是要转换的变量的引用。 参数可以接受 String、Array 和 Object 的类型。 mb_convert_variables() 假设所有的参数都具有同样的编码。

...

  • Additional vars.
  • 额外的 vars。

Return Values

  • The character encoding before conversion for success, or FALSE for failure.
  • 成功时返回转换前的字符编码,失败时返回 FALSE。

Examples

<?php
/**
* Created by PhpStorm.
* User: zhang
* Date: 2018/1/29
* Time: 16:29
*/ /* 转换变量 $post1、$post2 编码为内部(internal)编码 */
$post1 = "hello";
$post2 = "中国";
echo $post2 . PHP_EOL;
$interenc = mb_internal_encoding();
echo $interenc.PHP_EOL;
$inputenc = mb_convert_variables( $interenc,
"ASCII,UTF-8,SJIS-win",
$post1,
$post2 );
if ( $inputenc ) {
echo $post1 . PHP_EOL;
echo $post2 . PHP_EOL;
}

文章参考

转载注明出处

PHP之mb_convert_variables使用的更多相关文章

  1. PHP7函数大全(4553个函数)

    转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...

  2. PHP的学习--可变函数

    PHP 支持可变函数的概念.这意味着如果一个变量名后有圆括号,PHP 将寻找与变量的值同名的函数,并且尝试执行它.可变函数可以用来实现包括回调函数,函数表在内的一些用途. 可变函数不能用于例如 ech ...

  3. PHP类和函数注释大全

    每次要用PHP的某个功能的时候,都要去查一下,于是决定将PHP所有类和函数都整理出来,加上注释 大致实现 将php.jar文件解压,取出目录stubs 将stubs中的所有php文件中的注释去掉,并做 ...

  4. GeSHi Documentation

    GeSHi Documentation Version 1.0.8.11 Authors: © 2004 - 2007 Nigel McNie © 2007 - 2012 Benny Baumann ...

  5. php 多字节编码转换

    PHP 支持的编码 mb_convert_encoding — 转换字符的编码 string mb_convert_encoding ( string $str , string $to_encodi ...

  6. PHP 多字节字符串 函数

    参考资料 多字节字符编码方案和他们相关的问题相当复杂,超越了本文档的范围. 关于这些话题的更多信息请参考以下 URL 和其他资源. Unicode materials » http://www.uni ...

  7. PHP 实时生成并下载超大数据量的 Excel 文件

    //另外由于excel数据是从数据库里逐步读出然后写入输出流的所以需要将PHP的执行时间设长一点 //(默认30秒)set_time_limit(0)不对PHP执行时间做限制. set_time_li ...

  8. 用trie树实现输入提示功能,输入php函数名,提示php函数

    参照刘汝佳的trie树 结构体 #include "stdio.h" #include "stdlib.h" #include "string.h&q ...

  9. PHP-手册阅读

    配置选项: html_errors: 无意义的 HTML 标记符会使得出错信息很凌乱, 所以在外壳下阅读报错信息是十分困难的, 因此将该选项的默认值改为 FALSE implicit_flush: 在 ...

随机推荐

  1. SQL -- What Tables Queries are Used to Display the Counts in the Inventory Account Periods form (INVTTGPM.fmb) (Doc ID ID 357997.1)

    Applies to: Oracle Inventory Management - Version 11.5.9 to 12.1.3 [Release 11.5 to 12.1] Informatio ...

  2. c3p0--常见异常

    获取资源timeout: 异常信息如下: Caused by: java.sql.SQLException: An attempt by a client to checkout a Connecti ...

  3. CentOS 7上搭建Docker环境

    一.Docker介绍和安装 http://linux.cn/article-4340-1.html Docker 是一个开源工具,它可以让创建和管理 Linux 容器变得简单.容器就像是轻量级的虚拟机 ...

  4. .Net Core下使用Ajax,并传送参数到controllers

    可以使用URL拼接方式方法传参 .cshtml部分 @section Scripts{ @{ await Html.RenderPartialAsync("_ValidationScript ...

  5. ASP.NET 页面执行顺序详解

    今天整理了一下ASP执行过程,从.net页码的执行周期开始做一个详细的了解.我重写了页面的绝大多数方法.然后加载执行.所得的顺序如下. 方法是每个重写的事件中都输出一个字符,按字符打印出来的先后判断事 ...

  6. c#去除DataTable空列

    网上搜了好多,没找到能用的,自己写一个,有发现错误的给我留言. private void RemoveNULLColumns(ref DataTable data)//删除空列 { try { Dat ...

  7. mysql--视图,触发器,事务,存储过程

    一.视图 视图是一个虚拟表(非真实存在),是跑到内存中的表,真实表是硬盘上的表,怎么就得到了虚拟表,就是你查询的结果,只不过之前我们查询出来的虚拟表,从内存中取出来显示在屏幕上,内存中就没有了这些表的 ...

  8. sql—常用函数

    COUNT()函数 COUNT()函数返回匹配指定条件的行数 SQL COUNT(column_name) 语法 COUNT(column_name) 函数返回指定列的值的数目(NULL 不计入): ...

  9. 挂载U盘到linux中

        一.  挂载U盘到linux中,也可以是虚拟机中的linux 1. 首先插上U盘 2. fdisk -l 找到自己的U盘设备,并且记住文件系统类型,主要看空间大小来判断,比如是/dev/sdc ...

  10. 逻辑卷磁盘管理和dd命令

      底层PV 中层VG 上层LV   PE(phsical extent):在逻辑层次上,VG把PV分成固定大小的块,这些块就叫PE,默认为4M ,创建LV的过程就是分多少个PE的过程. 自动分区的过 ...