无需言 做自己 业 ,精于勤 荒于嬉.
- GD 和图像处理 函数 imagecolorclosest 取得与指定的颜色最接近的颜色的索引值
-
发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数
-
imagecolorclosest
(PHP 4, PHP 5, PHP 7, PHP 8)
imagecolorclosest — 取得与指定的颜色最接近的颜色的索引值
说明
imagecolorclosest(
resource$image,
int$red,
int$green,
int$blue
): int返回图像调色板中与指定的 RGB 值最“接近”的颜色。
指定的颜色与调色板中的每个颜色的“距离”的计算方法是把 RGB 值当成三维空间中点的坐标。
如果从文件创建了图像,只有图像中使用了的颜色会被辨析。仅出现在调色板中的颜色不会被辨析。
- GD 和图像处理 函数 gd_info 取得当前安装的 GD 库的信息
-
发表日期:2021-07-01 08:55:55 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php var_dump(gd_info()); ?>
- GD 和图像处理 函数 image_type_to_extension 取得图像类型的文件后缀
-
发表日期:2021-07-01 08:55:55 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创建图像实例$im = imagecreatetruecolor(100, 100); // 保存图像imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG)); imagedestroy($im); ?>
- 多字节字符串 函数 mb_substitute_character 设置/获取替代字符
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
示例1
<?php /* 设置为 Unicode U+3013 (GETA MARK) */ mb_substitute_character(0x3013); /* 设置十六进制格式 */ mb_substitute_character("long"); /* 显示当前设置 */ echo mb_substitute_character(); ?>
- 多字节字符串 函数 mb_strwidth 返回字符串的宽度
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
mb_strwidth
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_strwidth — 返回字符串的宽度
说明
mb_strwidth(string$str, string$encoding= mb_internal_encoding()): int返回 string 类型
str的宽度。多字节字符通常是单字节字符的两倍宽度。
字符宽度 字符 宽度 U+0000 - U+0019 0 U+0020 - U+1FFF 1 U+2000 - U+FF60 2 U+FF61 - U+FF9F 1 U+FFA0 - 2 参数
-
str -
待解码的 string。
-
encoding -
encoding参数为字符编码。如果省略或是null,则使用内部字符编码。
返回值
string
str的宽度。 -
- 多字节字符串 函数 mb_substr_count 统计字符串出现的次数
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
示例1
<?php echo mb_substr_count("This is a test", "is"); // 输出 2?>
- 多字节字符串 函数 mb_strtoupper 使字符串大写
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
示例1
<?php $str = "Mary Had A Little Lamb and She LOVED It So"; $str = mb_strtoupper($str); echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO?>
示例2
<?php $str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός"; $str = mb_strtoupper($str, 'UTF-8'); echo $str; // 打印了 ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ?>
- 多字节字符串 函数 mb_strrchr 查找指定字符在另一个字符串中最后一次的出现
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
mb_strrchr
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
mb_strrchr — 查找指定字符在另一个字符串中最后一次的出现
说明
mb_strrchr(
string$haystack,
string$needle,
bool$part= false,
string$encoding= mb_internal_encoding()
): stringmb_strrchr() 查找了
needle在haystack中最后一次出现的位置,并返回haystack的部分。 如果没有找到needle,它将返回false。参数
-
haystack -
在该字符串中查找
needle最后出现的位置 -
needle -
在
haystack中查找这个字符串 -
part -
决定这个函数返回
haystack的哪一部分。 如果设置为true,它将返回的字符是从haystack的开始到needle最后出现的位置。 如果设置为false,它将返回的字符是从needle最后出现的位置到haystack的末尾。 -
encoding -
使用的字符编码名称。如果省略了,则将使用内部编码。
返回值
返回
haystack的一部分。 或者在没有找到needle时返回false。参见
- strrchr() - 查找指定字符在字符串中的最后一次出现
- mb_strstr() - 查找字符串在另一个字符串里的首次出现
- mb_strrichr() - 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现
-
- 多字节字符串 函数 mb_substr 获取部分字符串
-
发表日期:2021-07-01 08:55:54 | 来源: | 分类:多字节字符串 函数
-
mb_substr
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
mb_substr — 获取部分字符串
说明
mb_substr(
string$str,
int$start,
int$length= NULL,
string$encoding= mb_internal_encoding()
): string根据字符数执行一个多字节安全的 substr() 操作。 位置是从
str的开始位置进行计数。 第一个字符的位置是 0。第二个字符的位置是 1,以此类推。参数
-
str -
从该 string 中提取子字符串。
-
start -
如果
start不是负数,返回的字符串会从str第start的位置开始,从 0 开始计数。举个例子,字符串 'abcdef',位置0的字符是 'a',位置2的字符是 'c',以此类推。如果
start是负数,返回的字符串是从str末尾处第start个字符开始的。 -
length -
str中要使用的最大字符数。如果省略了此参数或者传入了NULL,则会提取到字符串的尾部。 -
encoding -
encoding参数为字符编码。如果省略或是null,则使用内部字符编码。
返回值
mb_substr() 函数根据
start和length参数返回str中指定的部分。更新日志
版本 说明 5.4.8 length传入NULL,则从 start 提取到字符串的结尾处。 在之前的版本里,NULL会被当作0来处理。 -
- 多字节字符串 函数 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_options — Set/Get the default options for mbregex functions
说明
mb_regex_set_options(string|null$options=null): stringSets the default options described by
optionsfor 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 newliness '^'->'\A','$'->'\Z'p Same as both the mandsoptionsl 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
optionsis omitted ornull, it returns the string that describes the current options.更新日志
版本 说明 8.0.0 If the parameter optionsis given and notnull, the previous options are returned. Formerly, the current options have been returned.8.0.0 optionsis 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_encoding — Set/Get character encoding for multibyte regex
说明
mb_regex_encoding(string|null$encoding=null): string|boolSet/Get character encoding for a multibyte regex.
参数
-
encoding -
encoding参数为字符编码。如果省略或是null,则使用内部字符编码。
返回值
If
encodingis set, then 成功时返回true, 或者在失败时返回false。 In this case, the internal character encoding is NOT changed. Ifencodingis 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
Fromheader. This can be set with theadditional_headersparameter, 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. TheFromheader sets alsoReturn-Pathunder 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_regex_encoding() - Set/Get character encoding for multibyte regex
- mb_ereg() - Regular expression match with multibyte support
-
- 多字节字符串 函数 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_split — Given a multibyte string, return an array of its characters
说明
mb_str_split(string$string, int$length= 1, string|null$encoding=null): arrayThis 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
lengthparameter is specified, the string is broken down into chunks of the specified length in characters (not bytes). Theencodingparameter 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 falseon 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()
): intmb_stripos() 返回
needle在字符串haystack中首次出现位置的数值。 和 mb_strpos() 不同的是,mb_stripos() 是大小写不敏感的。 如果needle没找到,它将返回false。参数
-
haystack -
在这个字符串中查找获取
needle首次出现的位置 -
needle -
在
haystack中查找这个字符串 -
offset -
haystack里开始搜索的位置。如果是负数,就从字符串的尾部开始统计。 -
encoding -
使用的字符编码名称。 如果省略了它,将使用内部字符编码。
返回值
返回字符串
haystack中needle首次出现位置的数值。 如果没有找到needle,它将返回false。更新日志
版本 说明 7.1.0 支持 offset使用负数。 -
- 多字节字符串 函数 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()
): stringmb_strcut() 和 mb_substr() 类似,都是从字符串中提取子字符串,但是按字节数来执行,而不是字符个数。 如果截断位置位于多字节字符两个字节的中间,将于该字符的第一个字节开始执行。 这也是和 substr() 函数的不同之处,后者简单地将字符串在字节之间截断,这将导致一个畸形的字节序列。
参数
-
str -
要截断的 string。
-
start -
如果
start不是负数,返回的字符串会从str的第start字节位置开始,从 0 开始计数。举个例子,字符串 'abcdef',字节位置0的字符是 'a',字节位置2的字符是 'c',以此类推。如果
start是负数,返回的字符串是从str末尾处第start个字节开始的。 -
length -
字节长度。If omitted or
NULLis passed, extract all bytes to the end of the string. -
encoding -
encoding参数为字符编码。如果省略或是null,则使用内部字符编码。
返回值
mb_strcut() 根据
start和length参数返回str的一部分。更新日志
版本 说明 5.4.8 Passing NULLaslengthextracts all bytes to the end of the string. Prior to this versionNULLwas treated the same as0. -
- 多字节字符串 函数 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_internal_encoding() - 设置/获取内部字符编码
- grapheme_strlen() - Get string length in grapheme units
- iconv_strlen() - 返回字符串的字符数统计
- strlen() - 获取字符串长度
-
- 多字节字符串 函数 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()
): stringmb_strrichr() 大小写不敏感地查找指定
needle在haystack中最后一次的出现,并返回haystack的一部分。 和 mb_strrchr() 不同的是,mb_strrichr() 是大小写不敏感的。 如果needle没有找到,它将返回false。参数
-
haystack -
在该字符串中查找
needle的最后出现位置 -
needle -
在
needle中查找该字符串 -
part -
决定这个函数返回
haystack的哪一部分。 如果设置为true,它将返回的字符是从haystack的开始到needle最后出现的位置。 如果设置为false,它将返回的字符是从needle最后出现的位置到haystack的末尾。 -
encoding -
使用的字符编码名称。如果省略了,则将使用内部编码。
返回值
返回
haystack的一部分。 或者在没有找到needle时返回false。 -
- 多字节字符串 函数 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,则使用内部字符编码。
返回值
返回 string 的
haystack中needle首次出现位置的数值。 如果没有找到needle,它将返回false。更新日志
版本 说明 7.1.0 支持负数的 offset。 -
- 前端开发(1)
- 数据库(0)
- PHP(0)
- 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)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号