无需言 做自己 业 ,精于勤 荒于嬉.

多字节字符串 函数 mb_strrpos 查找字符串在一个字符串中最后出现的位置

发表日期:2021-07-01 08:55:53 | 来源: | 分类:多字节字符串 函数

mb_strrpos

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_strrpos查找字符串在一个字符串中最后出现的位置

说明

mb_strrpos(
    string $haystack,
    string $needle,
    int $offset = 0,
    string $encoding = mb_internal_encoding()
): int

基于字符数执行一个多字节安全的 strrpos() 操作。 needle 的位置是从 haystack 的开始进行统计的。 第一个字符的位置是 0,第二个字符的位置是 1。

参数

haystack

查找 needle 在这个 string 中最后出现的位置。

needle

haystack 中查找这个 string

offset
可以用于指定 string 里从任意字符数开始进行搜索。 负数的值将导致搜索会终止于指向 string 末尾的任意点。
encoding

encoding 参数为字符编码。如果省略或是 null,则使用内部字符编码。

返回值

返回 stringhaystack 中,needle 最后出现位置的数值。 如果没有找到 needle,它将返回 false

更新日志

版本 说明
5.2.0 增加了可选参数 offset

注释

注意: 从 PHP 5.2.0 开始,encoding 参数从第三个位置移到了第四个位置。 为实现向后兼容,可以将第三个参数指定为 encoding,但不建议这么做,在将来会移除这个特性。

参见

  • mb_strpos() - 查找字符串在另一个字符串中首次出现的位置
  • mb_internal_encoding() - 设置/获取内部字符编码
  • strrpos() - 计算指定字符串在目标字符串中最后一次出现的位置

阅读全文 »

多字节字符串 函数 mb_stristr 大小写不敏感地查找字符串在另一个字符串里的首次出现

发表日期:2021-07-01 08:55:53 | 来源: | 分类:多字节字符串 函数

mb_stristr

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

mb_stristr大小写不敏感地查找字符串在另一个字符串里的首次出现

说明

mb_stristr(
    string $haystack,
    string $needle,
    bool $before_needle = false,
    string $encoding = mb_internal_encoding()
): string

mb_strstr() 查找了 needlehaystack 中首次的出现并返回 haystack 的一部分。 和 mb_strstr() 不同的是,mb_stristr() 是大小写不敏感的。 如果 needle 没有找到,它将返回 false

参数

haystack

要获取 needle 首次出现的字符串。

needle

haystack 中查找这个字符串。

before_needle

决定这个函数返回 haystack 的哪一部分。 如果设置为 true,它返回 haystack 中从开始到 needle 出现位置的所有字符(不包括 needle)。 如果设置为 false,它返回 haystackneedle 出现位置到最后的所有字符(包括了 needle)。

encoding

要使用的字符编码名称。 如果省略该参数,将使用内部字符编码。

返回值

返回 haystack 的一部分,或者 needle 没找到则返回 false

参见

  • stristr() - strstr 函数的忽略大小写版本
  • strstr() - 查找字符串的首次出现
  • mb_strstr() - 查找字符串在另一个字符串里的首次出现

阅读全文 »

多字节字符串 函数 mb_strripos 大小写不敏感地在字符串中查找一个字符串最后出现的位置

发表日期:2021-07-01 08:55:53 | 来源: | 分类:多字节字符串 函数

mb_strripos

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

mb_strripos大小写不敏感地在字符串中查找一个字符串最后出现的位置

说明

mb_strripos(
    string $haystack,
    string $needle,
    int $offset = 0,
    string $encoding = mb_internal_encoding()
): int

mb_strripos() 基于字符数执行一个多字节安全的 strripos() 操作。 needle 的位置是从 haystack 的开始进行统计的。 第一个字符的位置是 0,第二个字符的位置是 1。 和 mb_strrpos() 不同的是,mb_strripos() 是大小写不敏感的。

参数

haystack

查找 needle 在这个字符串中最后出现的位置。

needle

haystack 中查找这个字符串。

offset

haystack 中开始搜索的位置。

encoding

使用的字符编码名称。如果省略了,则将使用内部编码。

返回值

返回字符串 haystackneedle 最后出现位置的数值。 如果没有找到 needle,它将返回 false

参见

  • strripos() - 计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)
  • strrpos() - 计算指定字符串在目标字符串中最后一次出现的位置
  • mb_strrpos() - 查找字符串在一个字符串中最后出现的位置

阅读全文 »

多字节字符串 函数 mb_strstr 查找字符串在另一个字符串里的首次出现

发表日期:2021-07-01 08:55:53 | 来源: | 分类:多字节字符串 函数

mb_strstr

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

mb_strstr查找字符串在另一个字符串里的首次出现

说明

mb_strstr(
    string $haystack,
    string $needle,
    bool $before_needle = false,
    string $encoding = mb_internal_encoding()
): string

mb_strstr() 查找了 needlehaystack 中首次的出现并返回 haystack 的一部分。 如果 needle 没有找到,它将返回 false

参数

haystack

要获取 needle 首次出现的字符串。

needle

haystack 中查找这个字符串。

before_needle

决定这个函数返回 haystack 的哪一部分。 如果设置为 true,它返回 haystack 中从开始到 needle 出现位置的所有字符(不包括 needle)。 如果设置为 false,它返回 haystackneedle 出现位置到最后的所有字符(包括了 needle)。

encoding

要使用的字符编码名称。 如果省略该参数,将使用内部字符编码。

返回值

返回 haystack 的一部分,或者 needle 没找到则返回 false

参见

  • stristr() - strstr 函数的忽略大小写版本
  • strstr() - 查找字符串的首次出现
  • mb_stristr() - 大小写不敏感地查找字符串在另一个字符串里的首次出现

阅读全文 »

多字节字符串 函数 mb_strtolower 使字符串小写

发表日期:2021-07-01 08:55:53 | 来源: | 分类:多字节字符串 函数

      示例1
<?php 
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = mb_strtolower($str);
echo $str;
 // 输出: mary had a little lamb and she loved it so?>

      示例2
<?php 
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtolower($str, 'UTF-8');
echo $str;
 // 输出 τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός?>

阅读全文 »

多字节字符串 函数 mb_ereg_search_getregs Retrieve the result from the last multibyte regular expression match

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_ereg_search_getregs

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_ereg_search_getregsRetrieve the result from the last multibyte regular expression match

说明

mb_ereg_search_getregs(): array|false

Retrieve the result from the last multibyte regular expression match

参数

此函数没有参数。

返回值

An array including the sub-string of matched part by last mb_ereg_search(), mb_ereg_search_pos(), mb_ereg_search_regs(). If there are some matches, the first element will have the matched sub-string, the second element will have the first part grouped with brackets, the third element will have the second part grouped with brackets, and so on. It returns false on error.

注释

注意:

mb_regex_encoding() 指定的内部编码或字符编码将会当作此函数用的字符编码。

参见

阅读全文 »

多字节字符串 函数 mb_ereg_search_regs Returns the matched part of a multibyte regular expression

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_ereg_search_regs

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_ereg_search_regsReturns the matched part of a multibyte regular expression

说明

mb_ereg_search_regs(string|null $pattern = null, string|null $options = null): array|false

Returns the matched part of a multibyte regular expression.

参数

pattern

The search pattern.

options

The search option. See mb_regex_set_options() for explanation.

返回值

mb_ereg_search_regs() executes the multibyte regular expression match, and if there are some matched part, it returns an array including substring of matched part as first element, the first grouped part with brackets as second element, the second grouped part as third element, and so on. It returns false on error.

更新日志

版本 说明
8.0.0 pattern and options are nullable now.

注释

注意:

mb_regex_encoding() 指定的内部编码或字符编码将会当作此函数用的字符编码。

参见

阅读全文 »

多字节字符串 函数 mb_ereg Regular expression match with multibyte support

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_ereg

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_eregRegular expression match with multibyte support

说明

mb_ereg(string $pattern, string $string, array &$matches = null): bool

Executes the regular expression match with multibyte support.

参数

pattern

The search pattern.

string

The search string.

matches

If matches are found for parenthesized substrings of pattern and the function is called with the third argument matches, the matches will be stored in the elements of the array matches. If no matches are found, matches is set to an empty array.

$matches[1] will contain the substring which starts at the first left parenthesis; $matches[2] will contain the substring starting at the second, and so on. $matches[0] will contain a copy of the complete string matched.

返回值

Returns whether pattern matches string.

更新日志

版本 说明
8.0.0 This function returns true on success now. Previously, it returned the byte length of the matched string if a match for pattern was found in string and matches was passed. If the optional parameter matches was not passed or the length of the matched string was 0, this function returned 1.
7.1.0 mb_ereg() will now set matches to an empty array, if nothing matched. Formerly, matches was not modified in that case.

注释

注意:

mb_regex_encoding() 指定的内部编码或字符编码将会当作此函数用的字符编码。

参见

  • mb_regex_encoding() - Set/Get character encoding for multibyte regex
  • mb_eregi() - Regular expression match ignoring case with multibyte support

阅读全文 »

多字节字符串 函数 mb_get_info 获取 mbstring 的内部设置

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_get_info

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_get_info获取 mbstring 的内部设置

说明

mb_get_info(string $type = "all"): mixed

mb_get_info() 返回 mbstring 参数的内部设定。

参数

type

如果没有设定 type 或者将其设定为 "all" 将会返回以下内容 "internal_encoding", "http_input", "http_output", "http_output_conv_mimetypes", "mail_charset", "mail_header_encoding", "mail_body_encoding", "illegal_chars", "encoding_translation", "language", "detect_order", "substitute_character""strict_detection"

如果 type 设定为类似 "internal_encoding", "http_input", "http_output", "http_output_conv_mimetypes", "mail_charset", "mail_header_encoding", "mail_body_encoding", "illegal_chars", "encoding_translation", "language", "detect_order", "substitute_character""strict_detection",将返回该参数的设置。

返回值

如果没有指定 type 将返回类型信息的数组,否则将返回指定 type 的信息。 或者在失败时返回 false

更新日志

版本 说明
8.0.0 参数 type 中的 "func_overload""func_overload_list" 不再被支持。

参见

阅读全文 »

多字节字符串 函数 mb_ereg_search_setpos Set start point of next regular expression match

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_ereg_search_setpos

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_ereg_search_setposSet start point of next regular expression match

说明

mb_ereg_search_setpos(int $offset): bool

mb_ereg_search_setpos() sets the starting point of a match for mb_ereg_search().

参数

offset

The position to set. If it is negative, it counts from the end of the string.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
7.1.0 Support for negative offsets has been added.

注释

注意:

mb_regex_encoding() 指定的内部编码或字符编码将会当作此函数用的字符编码。

参见

阅读全文 »

多字节字符串 函数 mb_http_output 设置/获取 HTTP 输出字符编码

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_http_output

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_http_output设置/获取 HTTP 输出字符编码

说明

mb_http_output(string $encoding = mb_http_output()): mixed

设置/获取 HTTP 输出字符编码。此函数被调用之后输出的内容会被转换成 encoding

参数

encoding

如果设置了 encodingmb_http_output() 设置 HTTP 输出字符编码为 encoding

如果省略了 encodingmb_http_output() 返回当前的 HTTP 输出字符编码。

返回值

如果省略了 encodingmb_http_output() 返回当前的 HTTP 输出字符编码。 否则成功时返回 true, 或者在失败时返回 false

参见

阅读全文 »

多字节字符串 函数 mb_http_input 检测 HTTP 输入字符编码

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_http_input

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_http_input检测 HTTP 输入字符编码

说明

mb_http_input(string $type = ""): mixed

检测 HTTP 输入字符的编码。

参数

type

设置的字符串指定了输入类型。 "G" 是 GET,"P" 是 POST,"C" 是 COOKIE,"S" 是 string,"L" 是 list,以及 "I" 是整个列表(将会返回 array)。 如果省略了 type,它将返回最后处理的一种输入类型。

返回值

每个 type 的字符编码名称。 如果 mb_http_input() 没有处理过任何指定的 HTTP 输入,它将返回 false

参见

阅读全文 »

多字节字符串 函数 mb_language 设置/获取当前的语言

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_language

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_language设置/获取当前的语言

说明

mb_language(string $language = mb_language()): mixed

设置/获取当前的语言。

参数

language

用于编码邮件信息。有效的语言有:"Japanese","ja","English","en" 和 "uni"(UTF-8)。 mb_send_mail() 使用了该设置来对邮件进行编码。

语言和它的设置,日文是 ISO-2022-JP/Base64,uni 是 UTF-8/Base64,英文是 ISO-8859-1/quoted。

返回值

如果设置了 language,并且 language 是有效的,它将返回 true。否则将返回 false。 当省略了 language 参数,它将返回语言名称的 string。如果之前没有设置过语言,则将返回 false

参见

阅读全文 »

多字节字符串 函数 mb_internal_encoding 设置/获取内部字符编码

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

      示例1
<?php 
/* 设置内部字符编码为 UTF-8 */
mb_internal_encoding("UTF-8");
/* 显示当前的内部字符编码*/
echo mb_internal_encoding();
?>

阅读全文 »

多字节字符串 函数 mb_eregi Regular expression match ignoring case with multibyte support

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_eregi

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_eregiRegular expression match ignoring case with multibyte support

说明

mb_eregi(string $pattern, string $string, array &$matches = null): bool

Executes the case insensitive regular expression match with multibyte support.

参数

pattern

The regular expression pattern.

string

The string being searched.

matches

If matches are found for parenthesized substrings of pattern and the function is called with the third argument matches, the matches will be stored in the elements of the array matches. If no matches are found, matches is set to an empty array.

$matches[1] will contain the substring which starts at the first left parenthesis; $matches[2] will contain the substring starting at the second, and so on. $matches[0] will contain a copy of the complete string matched.

返回值

Returns whether pattern matches string.

更新日志

版本 说明
8.0.0 This function returns true on success now. Previously, it returned the byte length of the matched string if a match for pattern was found in string and matches was passed. If the optional parameter matches was not passed or the length of the matched string was 0, this function returned 1.
7.1.0 mb_eregi() will now set matches to an empty array, if nothing matched. Formerly, matches was not modified in that case.

注释

注意:

mb_regex_encoding() 指定的内部编码或字符编码将会当作此函数用的字符编码。

参见

阅读全文 »

多字节字符串 函数 mb_eregi_replace Replace regular expression with multibyte support ignoring case

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_eregi_replace

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

mb_eregi_replaceReplace regular expression with multibyte support ignoring case

说明

mb_eregi_replace(
    string $pattern,
    string $replacement,
    string $string,
    string|null $options = null
): string|false|null

Scans string for matches to pattern, then replaces the matched text with replacement.

参数

pattern

The regular expression pattern. Multibyte characters may be used. The case will be ignored.

replacement

The replacement text.

string

The searched string.

options
The search option. See mb_regex_set_options() for explanation.

返回值

The resultant string or false on error. If string is not valid for the current encoding, null is returned.

更新日志

版本 说明
8.0.0 options is nullable now.
7.1.0 The function checks whether string is valid for the current encoding.
7.1.0 The e modifier has been deprecated.

注释

注意:

mb_regex_encoding() 指定的内部编码或字符编码将会当作此函数用的字符编码。

警告

处理非信任的输入时从不使用 e 修饰符,就不会转码(即调用 preg_replace())。不注意这些会很可能会导致应用程序引发远程代码执行的漏洞。

参见

阅读全文 »

多字节字符串 函数 mb_output_handler 在输出缓冲中转换字符编码的回调函数

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

      示例1
<?php 
mb_http_output("UTF-8");
ob_start("mb_output_handler");
?>

阅读全文 »

多字节字符串 函数 mb_list_encodings 返回所有支持编码的数组

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

      示例1
<?php 
print_r(mb_list_encodings());
?>

阅读全文 »

多字节字符串 函数 mb_preferred_mime_name 获取 MIME 字符串

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

      示例1
<?php 
$outputenc = "sjis-win";
mb_http_output($outputenc);
ob_start("mb_output_handler");
header("Content-Type: text/html;
 charset=" . mb_preferred_mime_name($outputenc));
?>

阅读全文 »

多字节字符串 函数 mb_parse_str 解析 GET/POST/COOKIE 数据并设置全局变量

发表日期:2021-07-01 08:55:52 | 来源: | 分类:多字节字符串 函数

mb_parse_str

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_parse_str解析 GET/POST/COOKIE 数据并设置全局变量

说明

mb_parse_str(string $encoded_string, array &$result = ?): bool

解析 GET/POST/COOKIE 数据并设置全局变量。 由于 PHP 不提供原始 POST/COOKIE 数据,目前它仅能够用于 GET 数据。 它解析了 URL 编码过的数据,检测其编码,并转换编码为内部编码,然后设置其值为 arrayresult 或者全局变量。

参数

encoded_string

URL 编码过的数据。

result

一个 array,包含解码过的、编码转换后的值。

返回值

成功时返回 true, 或者在失败时返回 false

参见

阅读全文 »

全部博文(1589)
集速网 copyRight © 2015-2025 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。