iconv 函数 业 ,精于勤 荒于嬉.
- iconv 函数 iconv_get_encoding 获取 iconv 扩展的内部配置变量
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:iconv 函数
-
示例1
<?php iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "ISO-8859-1"); var_dump(iconv_get_encoding('all')); </pre>
- iconv 函数 iconv_mime_decode_headers 一次性解码多个 MIME 头字段
-
发表日期:2021-07-01 08:55:45 | 来源: | 分类:iconv 函数
-
示例1
<?php $headers_string = <<<EOFSubject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=To: example@example.comDate: Thu, 1 Jan 1970 00:00:00 +0000Message-Id: <example@example.com>Received: from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000EOF; $headers = iconv_mime_decode_headers($headers_string, 0, "ISO-8859-1"); print_r($headers); ?>
- iconv 函数 iconv_mime_decode 解码一个MIME头字段
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
示例1
<?php //返回结果: "Subject: Prüfung Prüfung" echo iconv_mime_decode("Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=", 0, "ISO-8859-1"); ?>
- iconv 函数 iconv_mime_encode Composes a MIME header field
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
示例1
<?php $preferences = array("input-charset" => "ISO-8859-1","output-charset"=>"UTF-8","line-length"=>76,"line-break-chars" => "\n"); $preferences["scheme"] = "Q"; // This yields "Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?=" echo iconv_mime_encode("Subject", "Prüfung Prüfung", $preferences); $preferences["scheme"] = "B"; // This yields "Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=" echo iconv_mime_encode("Subject", "Prüfung Prüfung", $preferences); ?>
- iconv 函数 iconv_set_encoding 为字符编码转换设定当前设置
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
示例1
<?php iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "ISO-8859-1"); ?>
- iconv 函数 iconv_strlen 返回字符串的字符数统计
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
iconv_strlen
(PHP 5, PHP 7, PHP 8)
iconv_strlen — 返回字符串的字符数统计
说明
iconv_strlen(string$str, string$charset= ini_get("iconv.internal_encoding")): int和 strlen() 不同的是,iconv_strlen() 统计了给定的字节序列
str中出现字符数的统计,基于指定的字符集,其产生的结果不一定和字符字节数相等。参数
-
str -
该字符串。
-
charset -
如果省略了
charset参数,假设str的编码为 iconv.internal_encoding。
返回值
返回
str字符数的统计,是整型。参见
- grapheme_strlen() - Get string length in grapheme units
- mb_strlen() - 获取字符串的长度
- strlen() - 获取字符串长度
-
- iconv 函数 iconv_strpos Finds position of first occurrence of a needle within a haystack
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
iconv_strpos
(PHP 5, PHP 7, PHP 8)
iconv_strpos — Finds position of first occurrence of a needle within a haystack
说明
iconv_strpos(
string$haystack,
string$needle,
int$offset= 0,
string|null$encoding=null
): int|falseFinds position of first occurrence of a
needlewithin ahaystack.In contrast to strpos(), the return value of iconv_strpos() is the number of characters that appear before the needle, rather than the offset in bytes to the position where the needle has been found. The characters are counted on the basis of the specified character set
encoding.参数
-
haystack -
The entire string.
-
needle -
The searched substring.
-
offset -
The optional
offsetparameter specifies the position from which the search should be performed. If the offset is negative, it is counted from the end of the string. -
encoding -
If
encodingparameter is omitted ornull,stringare assumed to be encoded in iconv.internal_encoding.
If
haystackorneedleis not a string, it is converted to a string and applied as the ordinal value of a character.返回值
Returns the numeric position of the first occurrence of
needleinhaystack.If
needleis not found, iconv_strpos() will returnfalse.警告此函数可能返回布尔值
false,但也可能返回等同于false的非布尔值。请阅读 布尔类型章节以获取更多信息。应使用 === 运算符来测试此函数的返回值。更新日志
版本 说明 8.0.0 encodingis nullable now.7.1.0 Support for negative offsets has been added.参见
- strpos() - 查找字符串首次出现的位置
- iconv_strrpos() - Finds the last occurrence of a needle within a haystack
- mb_strpos() - 查找字符串在另一个字符串中首次出现的位置
-
- iconv 函数 iconv_strrpos Finds the last occurrence of a needle within a haystack
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
iconv_strrpos
(PHP 5, PHP 7, PHP 8)
iconv_strrpos — Finds the last occurrence of a needle within a haystack
说明
iconv_strrpos(string$haystack, string$needle, string|null$encoding=null): int|falseFinds the last occurrence of a
needlewithin ahaystack.In contrast to strrpos(), the return value of iconv_strrpos() is the number of characters that appear before the needle, rather than the offset in bytes to the position where the needle has been found. The characters are counted on the basis of the specified character set
encoding.参数
-
haystack -
The entire string.
-
needle -
The searched substring.
-
encoding -
If
encodingparameter is omitted ornull,stringare assumed to be encoded in iconv.internal_encoding.
If
haystackorneedleis not a string, it is converted to a string and applied as the ordinal value of a character.返回值
Returns the numeric position of the last occurrence of
needleinhaystack.If
needleis not found, iconv_strrpos() will returnfalse.警告此函数可能返回布尔值
false,但也可能返回等同于false的非布尔值。请阅读 布尔类型章节以获取更多信息。应使用 === 运算符来测试此函数的返回值。更新日志
版本 说明 8.0.0 encodingis nullable now.参见
- strrpos() - 计算指定字符串在目标字符串中最后一次出现的位置
- iconv_strpos() - Finds position of first occurrence of a needle within a haystack
- mb_strrpos() - 查找字符串在一个字符串中最后出现的位置
-
- iconv 函数 iconv_substr 截取字符串的部分
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
iconv_substr
(PHP 5, PHP 7, PHP 8)
iconv_substr — 截取字符串的部分
说明
iconv_substr(
string$str,
int$offset,
int$length= iconv_strlen($str, $charset),
string$charset= ini_get("iconv.internal_encoding")
): string根据
offset和length参数指定str截取的部分。参数
-
str -
原始字符串。
-
offset -
如果
offset是非负数,iconv_substr() 从str开头第offset个字符开始截出部分,从 0 开始计数。如果
offset是负数,iconv_substr() 从str末尾向前offset个字符开始截取。 -
length -
如果指定了
length并且是正数,返回的值从offset截取部分,最多包含length个字符(取决于string的长度)。如果传入了负数的
length, iconv_substr() 将从第offset个字符到离末尾length个字符截出str的部分。 如果offset也是负数,则开始位置计算规则的解释见以上。 -
charset -
如果省略了参数
charset,string的编码被认定为 iconv.internal_encoding。注意,
offset和length参数总是被认为字符表现的偏移,基于charset检测到的字符集进行统计计算,而相对应的 substr() 则是基于字节的位移来计算。
返回值
返回
offset和length参数指定的str的部分。如果
str比offset字符数更短,将会返回false。 如果str是offset个字符的长度,将返回空字符串。更新日志
版本 说明 7.0.11 如果 str等长于offset个字符, 将返回空字符串。之前的版本里,这种情况是会返回false的。 -
- iconv 函数 iconv 字符串按要求的字符编码来转换
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
示例1
<?php $text = "This is the Euro symbol '€'."; echo 'Original : ', $text, PHP_EOL; echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL; echo 'IGNORE : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL; echo 'Plain : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL; ?>
- iconv 函数 ob_iconv_handler 以输出缓冲处理程序转换字符编码
-
发表日期:2021-07-01 08:55:46 | 来源: | 分类:iconv 函数
-
示例1
<?php iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "ISO-8859-1"); ob_start("ob_iconv_handler"); // 开始输出缓冲 ?>
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
宁公网安备 64010402001209号