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

多字节字符串 函数 mb_regex_set_options Set/Get the default options for mbregex functions

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

mb_regex_set_options

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

mb_regex_set_optionsSet/Get the default options for mbregex functions

说明

mb_regex_set_options(string|null $options = null): string

Sets the default options described by options for multibyte regex functions.

参数

options

The options to set. This is a string where each character is an option. To set a mode, the mode character must be the last one set, however there can only be set one mode but multiple options.

Regex options
Option Meaning
i Ambiguity match on
x Enables extended pattern form
m '.' matches with newlines
s '^' -> '\A', '$' -> '\Z'
p Same as both the m and s options
l Finds longest matches
n Ignores empty matches
e eval() resulting code
Regex syntax modes
Mode Meaning
j Java (Sun java.util.regex)
u GNU regex
g grep
c Emacs
r Ruby
z Perl
b POSIX Basic regex
d POSIX Extended regex

返回值

The previous options. If options is omitted or null, it returns the string that describes the current options.

更新日志

版本 说明
8.0.0 If the parameter options is given and not null, the previous options are returned. Formerly, the current options have been returned.
8.0.0 options is nullable now.

参见

  • mb_split() - 使用正则表达式分割多字节字符串
  • mb_ereg() - Regular expression match with multibyte support
  • mb_eregi() - Regular expression match ignoring case with multibyte support

阅读全文 »

多字节字符串 函数 mb_regex_encoding Set/Get character encoding for multibyte regex

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

mb_regex_encoding

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

mb_regex_encodingSet/Get character encoding for multibyte regex

说明

mb_regex_encoding(string|null $encoding = null): string|bool

Set/Get character encoding for a multibyte regex.

参数

encoding

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

返回值

If encoding is set, then 成功时返回 true, 或者在失败时返回 false。 In this case, the internal character encoding is NOT changed. If encoding is omitted, then the current character encoding name for a multibyte regex is returned.

更新日志

版本 说明
8.0.0 现在 encoding 可以为 null。

参见

阅读全文 »

多字节字符串 函数 mb_send_mail 发送编码过的邮件

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

mb_send_mail

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

mb_send_mail发送编码过的邮件

说明

mb_send_mail(
    string $to,
    string $subject,
    string $message,
    string $additional_headers = null,
    string $additional_parameter = null
): bool

发送邮件。邮件头和内容根据 mb_language() 设置来转换编码。 这是 mail() 的一个包装器函数,所以详情参见 mail()

参数

to

被发送到该邮件地址。可通过逗号分隔地址的 to 来指定多个收件人。 该参数不会被自动编码。

subject

邮件标题。

message

邮件消息。

additional_headers(可选)

String to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). Validate parameter not to be injected unwanted headers by attackers.

注意:

When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.

Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

注意:

If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.

additional_parameter

additional_parameter 是一个 MTA 命令行参数。 在使用 sendmail 时对设置正确的返回路径头很有帮助。

This parameter is escaped by escapeshellcmd() internally to prevent command execution. escapeshellcmd() prevents command execution, but allows to add addtional parameters. For security reason, this parameter should be validated.

Since escapeshellcmd() is applied automatically, some characters that are allowed as email addresses by internet RFCs cannot be used. Programs that are required to use these characters mail() cannot be used.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.

返回值

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

参见

阅读全文 »

多字节字符串 函数 mb_split 使用正则表达式分割多字节字符串

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

mb_split

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

mb_split使用正则表达式分割多字节字符串

说明

mb_split(string $pattern, string $string, int $limit = -1): array

使用正则表达式 pattern 分割多字节 string 并返回结果 array

参数

pattern

正则表达式。

string

待分割的 string

limit
如果指定了可选参数 limit,将最多分割为 limit 个元素。

返回值

array 的结果。

注释

注意:

The character encoding specified by mb_regex_encoding() will be used as the character encoding for this function by default.

参见

阅读全文 »

多字节字符串 函数 mb_str_split Given a multibyte string, return an array of its characters

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

mb_str_split

(PHP 7 >= 7.4.0, PHP 8)

mb_str_splitGiven a multibyte string, return an array of its characters

说明

mb_str_split(string $string, int $length = 1, string|null $encoding = null): array

This function will return an array of strings, it is a version of str_split() with support for encodings of variable character size as well as fixed-size encodings of 1,2 or 4 byte characters. If the length parameter is specified, the string is broken down into chunks of the specified length in characters (not bytes). The encoding parameter can be optionally specified and it is good practice to do so.

参数

string

The string to split into characters or chunks.

length

If specified, each element of the returned array will be composed of multiple characters instead of a single character.

encoding

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

A string specifying one of the supported encodings.

返回值

mb_str_split() returns an array of strings.

更新日志

版本 说明
8.0.0 现在 encoding 可以为 null。
8.0.0 This function no longer returns false on failure.

参见

阅读全文 »

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

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

mb_stripos

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

mb_stripos大小写不敏感地查找字符串在另一个字符串中首次出现的位置

说明

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

mb_stripos() 返回 needle 在字符串 haystack 中首次出现位置的数值。 和 mb_strpos() 不同的是,mb_stripos() 是大小写不敏感的。 如果 needle 没找到,它将返回 false

参数

haystack

在这个字符串中查找获取 needle 首次出现的位置

needle

haystack 中查找这个字符串

offset

haystack 里开始搜索的位置。如果是负数,就从字符串的尾部开始统计。

encoding

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

返回值

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

更新日志

版本 说明
7.1.0 支持 offset 使用负数。

参见

  • stripos() - 查找字符串首次出现的位置(不区分大小写)
  • strpos() - 查找字符串首次出现的位置
  • mb_strpos() - 查找字符串在另一个字符串中首次出现的位置

阅读全文 »

多字节字符串 函数 mb_strimwidth 获取按指定宽度截断的字符串

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

      示例1
<?php 
echo mb_strimwidth("Hello World", 0, 10, "...");
// 输出 Hello W...?>

阅读全文 »

多字节字符串 函数 mb_strcut 获取字符的一部分

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

mb_strcut

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

mb_strcut获取字符的一部分

说明

mb_strcut(
    string $str,
    int $start,
    int $length = NULL,
    string $encoding = mb_internal_encoding()
): string

mb_strcut()mb_substr() 类似,都是从字符串中提取子字符串,但是按字节数来执行,而不是字符个数。 如果截断位置位于多字节字符两个字节的中间,将于该字符的第一个字节开始执行。 这也是和 substr() 函数的不同之处,后者简单地将字符串在字节之间截断,这将导致一个畸形的字节序列。

参数

str

要截断的 string

start

如果 start 不是负数,返回的字符串会从 str 的第 start 字节位置开始,从 0 开始计数。举个例子,字符串 'abcdef',字节位置 0 的字符是 'a',字节位置 2 的字符是 'c',以此类推。

如果 start 是负数,返回的字符串是从 str 末尾处第 start 个字节开始的。

length

字节长度。If omitted or NULL is passed, extract all bytes to the end of the string.

encoding

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

返回值

mb_strcut() 根据 startlength 参数返回 str 的一部分。

更新日志

版本 说明
5.4.8 Passing NULL as length extracts all bytes to the end of the string. Prior to this version NULL was treated the same as 0.

参见

阅读全文 »

多字节字符串 函数 mb_strlen 获取字符串的长度

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

mb_strlen

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

mb_strlen获取字符串的长度

说明

mb_strlen(string $str, string $encoding = mb_internal_encoding()): mixed

获取一个 string 的长度。

参数

str

要检查长度的字符串

encoding

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

返回值

返回具有 encoding 编码的字符串 str 包含的字符数。 多字节的字符被计为 1。

如果给定的 encoding 无效则返回 false

参见

阅读全文 »

多字节字符串 函数 mb_strrichr 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现

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

mb_strrichr

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

mb_strrichr大小写不敏感地查找指定字符在另一个字符串中最后一次的出现

说明

mb_strrichr(
    string $haystack,
    string $needle,
    bool $part = false,
    string $encoding = mb_internal_encoding()
): string

mb_strrichr() 大小写不敏感地查找指定 needlehaystack 中最后一次的出现,并返回 haystack 的一部分。 和 mb_strrchr() 不同的是,mb_strrichr() 是大小写不敏感的。 如果 needle 没有找到,它将返回 false

参数

haystack

在该字符串中查找 needle 的最后出现位置

needle

needle 中查找该字符串

part

决定这个函数返回 haystack 的哪一部分。 如果设置为 true,它将返回的字符是从 haystack 的开始到 needle 最后出现的位置。 如果设置为 false,它将返回的字符是从 needle 最后出现的位置到 haystack 的末尾。

encoding

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

返回值

返回 haystack 的一部分。 或者在没有找到 needle 时返回 false

参见

  • mb_stristr() - 大小写不敏感地查找字符串在另一个字符串里的首次出现
  • mb_strrchr() - 查找指定字符在另一个字符串中最后一次的出现

阅读全文 »

多字节字符串 函数 mb_strpos 查找字符串在另一个字符串中首次出现的位置

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

mb_strpos

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

mb_strpos查找字符串在另一个字符串中首次出现的位置

说明

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

查找 string 在一个 string 中首次出现的位置。

基于字符数执行一个多字节安全的 strpos() 操作。 第一个字符的位置是 0,第二个字符的位置是 1,以此类推。

参数

haystack

要被检查的 string

needle

haystack 中查找这个字符串。 和 strpos() 不同的是,数字的值不会被当做字符的顺序值。

offset

搜索位置的偏移。如果没有提供该参数,将会使用 0。负数的 offset 会从字符串尾部开始统计。

encoding

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

返回值

返回 stringhaystackneedle 首次出现位置的数值。 如果没有找到 needle,它将返回 false

更新日志

版本 说明
7.1.0 支持负数的 offset

参见

阅读全文 »

多字节字符串 函数 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" 不再被支持。

参见

阅读全文 »

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