无需言 做自己 业 ,精于勤 荒于嬉.
- 字符串 函数 str_contains Determine if a string contains a given substring
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php if (str_contains('abc', '')) { echo "Checking the existence of the empty string will always return true"; } ?>示例2
<?php $string = 'The lazy fox jumped over the fence'; if (str_contains($string, 'lazy')) { echo "The string 'lazy' was found in the string\n"; } if (str_contains($string, 'Lazy')) { echo 'The string "Lazy" was found in the string'; } else { echo '"Lazy" was not found because the case does not match'; } ?>
- 字符串 函数 str_pad 使用另一个字符串填充字符串为指定长度
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php $input = "Alien"; echo str_pad($input, 10); // 输出 "Alien "echo str_pad($input, 10, "-=", STR_PAD_LEFT); // 输出 "-=-=-Alien"echo str_pad($input, 10, "_", STR_PAD_BOTH); // 输出 "__Alien___"echo str_pad($input, 6, "___"); // 输出 "Alien_"echo str_pad($input, 3, "*"); // 输出 "Alien"?>
- 字符串 函数 str_repeat 重复一个字符串
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php echo str_repeat("-=", 10); ?>
- 字符串 函数 str_replace 子字符串替换
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php // 赋值: <body text='black'>$bodytag = str_replace("%body%", "black", "<body text='%body%'>"); // 赋值: Hll Wrld f PHP$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); $onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); // 赋值: You should eat pizza, beer, and ice cream every day$phrase = "You should eat fruits, vegetables, and fiber every day."; $healthy = array("fruits", "vegetables", "fiber"); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase); // 赋值: 2$str = str_replace("ll", "", "good golly miss molly!", $count); echo $count; ?>示例2
<?php // 替换顺序$str = "Line 1\nLine 2\rLine 3\r\nLine 4\n"; $order = array("\r\n", "\n", "\r"); $replace = '<br />'; // 首先替换 \r\n 字符,因此它们不会被两次转换$newstr = str_replace($order, $replace, $str); // 输出 F ,因为 A 被 B 替换,B 又被 C 替换,以此类推...// 由于从左到右依次替换,最终 E 被 F 替换$search = array('A', 'B', 'C', 'D', 'E'); $replace = array('B', 'C', 'D', 'E', 'F'); $subject = 'A'; echo str_replace($search, $replace, $subject); // 输出: apearpearle pear// 由于上面提到的原因$letters = array('a', 'p'); $fruit = array('apple', 'pear'); $text = 'a p'; $output = str_replace($letters, $fruit, $text); echo $output; ?>
- 字符串 函数 str_rot13 对字符串执行 ROT13 转换
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php echo str_rot13('PHP 4.3.0'); // CUC 4.3.0?>
- 字符串 函数 str_shuffle 随机打乱一个字符串
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php $str = 'abcdef'; $shuffled = str_shuffle($str); // 输出类似于: bfdaececho $shuffled; ?>
- 字符串 函数 str_ireplace str_replace() 的忽略大小写版本
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php $bodytag = str_ireplace("%body%", "black", "<body text=%BODY%>"); echo $bodytag; // <body text=black>?>
- 字符串 函数 str_word_count 返回字符串中单词的使用情况
-
发表日期:2021-07-01 10:23:23 | 来源: | 分类:字符串 函数
-
示例1
<?php $str = "Hello fri3nd, you're looking good today!"; print_r(str_word_count($str, 1)); print_r(str_word_count($str, 2)); print_r(str_word_count($str, 1, 'àáãç3')); echo str_word_count($str); ?>
- 字符串 函数 md5 计算字符串的 MD5 散列值
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php $str = 'apple'; if (md5($str) === '1f3870be274f6c49b3e31a0c6728957f') { echo "Would you like a green or red apple?"; } ?>
- 字符串 函数 nl_langinfo Query language and locale information
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
nl_langinfo
(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)
nl_langinfo — Query language and locale information
说明
nl_langinfo(int$item): string|falsenl_langinfo() is used to access individual elements of the locale categories. Unlike localeconv(), which returns all of the elements, nl_langinfo() allows you to select any specific element.
参数
-
item -
itemmay be an integer value of the element or the constant name of the element. The following is a list of constant names foritemthat may be used and their description. Some of these constants may not be defined or hold no value for certain locales.nl_langinfo Constants Constant Description LC_TIME Category Constants ABDAY_(1-7)Abbreviated name of n-th day of the week. DAY_(1-7)Name of the n-th day of the week (DAY_1 = Sunday). ABMON_(1-12)Abbreviated name of the n-th month of the year. MON_(1-12)Name of the n-th month of the year. AM_STRString for Ante meridian. PM_STRString for Post meridian. D_T_FMTString that can be used as the format string for strftime() to represent time and date. D_FMTString that can be used as the format string for strftime() to represent date. T_FMTString that can be used as the format string for strftime() to represent time. T_FMT_AMPMString that can be used as the format string for strftime() to represent time in 12-hour format with ante/post meridian. ERAAlternate era. ERA_YEARYear in alternate era format. ERA_D_T_FMTDate and time in alternate era format (string can be used in strftime()). ERA_D_FMTDate in alternate era format (string can be used in strftime()). ERA_T_FMTTime in alternate era format (string can be used in strftime()). LC_MONETARY Category Constants INT_CURR_SYMBOLInternational currency symbol. CURRENCY_SYMBOLLocal currency symbol. CRNCYSTRSame value as CURRENCY_SYMBOL.MON_DECIMAL_POINTDecimal point character. MON_THOUSANDS_SEPThousands separator (groups of three digits). MON_GROUPINGLike "grouping"element.POSITIVE_SIGNSign for positive values. NEGATIVE_SIGNSign for negative values. INT_FRAC_DIGITSInternational fractional digits. FRAC_DIGITSLocal fractional digits. P_CS_PRECEDESReturns 1 if CURRENCY_SYMBOLprecedes a positive value.P_SEP_BY_SPACEReturns 1 if a space separates CURRENCY_SYMBOLfrom a positive value.N_CS_PRECEDESReturns 1 if CURRENCY_SYMBOLprecedes a negative value.N_SEP_BY_SPACEReturns 1 if a space separates CURRENCY_SYMBOLfrom a negative value.P_SIGN_POSN-
Returns 0 if parentheses surround the quantity and
CURRENCY_SYMBOL. -
Returns 1 if the sign string precedes the quantity and
CURRENCY_SYMBOL. -
Returns 2 if the sign string follows the quantity and
CURRENCY_SYMBOL. -
Returns 3 if the sign string immediately precedes the
CURRENCY_SYMBOL. -
Returns 4 if the sign string immediately follows the
CURRENCY_SYMBOL.
N_SIGN_POSNLC_NUMERIC Category Constants DECIMAL_POINTDecimal point character. RADIXCHARSame value as DECIMAL_POINT.THOUSANDS_SEPSeparator character for thousands (groups of three digits). THOUSEPSame value as THOUSANDS_SEP.GROUPINGLC_MESSAGES Category Constants YESEXPRRegex string for matching "yes"input.NOEXPRRegex string for matching "no"input.YESSTROutput string for "yes".NOSTROutput string for "no".LC_CTYPE Category Constants CODESETReturn a string with the name of the character encoding. -
Returns 0 if parentheses surround the quantity and
返回值
Returns the element as a string, or
falseifitemis not valid.注释
注意: 此函数未在 Windows 平台下实现。
-
- 字符串 函数 metaphone Calculate the metaphone key of a string
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php var_dump(metaphone('programming')); var_dump(metaphone('programmer')); ?>示例2
<?php var_dump(metaphone('programming', 5)); var_dump(metaphone('programmer', 5)); ?>示例3
<?php var_dump(metaphone('Asterix', 5)); ?>
- 字符串 函数 money_format 将数字格式化成货币字符串
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php $number = 1234.56; // 让我们打印 en_US locale 的国际化格式setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number) . "\n"; // USD 1,234.56// 意大利国家的格式,带两位浮点小数`setlocale(LC_MONETARY, 'it_IT'); echo money_format('%.2n', $number) . "\n"; // Eu 1.234,56// 负数的使用$number = -1234.5672; // 美国国家的格式,使用圆括号 () 标记负数。// 左侧精度使用十位setlocale(LC_MONETARY, 'en_US'); echo money_format('%(#10n', $number) . "\n"; // ($ 1,234.57)// 相似的格式,添加了右侧两位小数点的精度,同时用 * 来填充echo money_format('%=*(#10.2n', $number) . "\n"; // ($********1,234.57)// 让我们左对齐,14位宽,左侧八位,右侧两位,不带分组字符// de_DE 的国际化格式setlocale(LC_MONETARY, 'de_DE'); echo money_format('%=*^-14#8.2i', 1234.56) . "\n"; // Eu 1234,56****/ / 让我们在格式字符串前后,添加一些简介setlocale(LC_MONETARY, 'en_GB'); $fmt = 'The final value is %i (after a 10%% discount)'; echo money_format($fmt, 1234.56) . "\n"; // The final value is GBP 1,234.56 (after a 10% discount)?>
- 字符串 函数 localeconv Get numeric formatting information
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php if (false !== setlocale(LC_ALL, 'nl_NL.UTF-8@euro')) { $locale_info = localeconv(); print_r($locale_info); } ?>
- 字符串 函数 number_format 以千位分隔符方式格式化一个数字
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php $number = 1234.56; // english notation (default)$english_format_number = number_format($number); // 1,235// French notation$nombre_format_francais = number_format($number, 2, ',', ' '); // 1 234,56$number = 1234.5678; // english notation without thousands separator$english_format_number = number_format($number, 2, '.', ''); // 1234.57?>
- 字符串 函数 nl2br 在字符串所有新行之前插入 HTML 换行标记
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php echo nl2br("foo isn't\n bar"); ?>示例2
<?php echo nl2br("Welcome\r\nThis is my HTML document", false); ?>示例3
<?php $string = "This\r\nis\n\ra\nstring\r"; echo nl2br($string); ?>
- 字符串 函数 print 输出字符串
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php print("Hello World"); print "print() also works without parentheses."; print "This spansmultiple lines. The newlines will beoutput as well"; print "This spans\nmultiple lines. The newlines will be\noutput as well."; print "escaping characters is done \"Like this\"."; // 可以在打印语句中使用变量$foo = "foobar"; $bar = "barbaz"; print "foo is $foo"; // foo is foobar// 也可以使用数组$bar = array("value" => "foo"); print "this is { $bar['value']} !"; // this is foo !// 使用单引号将打印变量名,而不是变量的值print 'foo is $foo'; // foo is $foo// 如果没有使用任何其他字符,可以仅打印变量print $foo; // foobarprint <<<ENDThis uses the "here document" syntax to outputmultiple lines with $variable interpolation. Notethat the here document terminator must appear on aline with just a semicolon no extra whitespace!END; ?>
- 字符串 函数 quoted_printable_decode 将 quoted-printable 字符串转换为 8-bit 字符串
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
quoted_printable_decode
(PHP 4, PHP 5, PHP 7, PHP 8)
quoted_printable_decode — 将 quoted-printable 字符串转换为 8-bit 字符串
说明
quoted_printable_decode(string$str): string该函数返回 quoted-printable 解码之后的 8-bit 字符串 (参考 » RFC2045 的6.7章节,而不是 » RFC2821 的4.5.2章节,so additional periods are not stripped from the beginning of line)
该函数与 imap_qprint() 函数十分相似,但是该函数不需要依赖 IMAP 模块。
参数
-
str -
输入的字符串。
返回值
返回的 8-bit 二进制字符串。
-
- 字符串 函数 ord 转换字符串第一个字节为 0-255 之间的值
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
示例1
<?php $str = "\n"; if (ord($str) == 10) { echo "The first character of \$str is a line feed.\n"; } ?>示例2
<?php declare(encoding='UTF-8'); $str = "22"; for ( $pos=0; $pos < strlen($str); $pos ++ ) { $byte = substr($str, $pos); echo 'Byte ' . $pos . ' of $str has value ' . ord($byte) . PHP_EOL; } ?>
- 字符串 函数 printf 输出格式化字符串
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
printf
(PHP 4, PHP 5, PHP 7, PHP 8)
printf — 输出格式化字符串
说明
printf(string$format, mixed$args= ?, mixed$...= ?): int依据
format格式参数产生输出。返回值
返回输出字符串的长度。
- 字符串 函数 quotemeta 转义元字符集
-
发表日期:2021-07-01 10:23:22 | 来源: | 分类:字符串 函数
-
quotemeta
(PHP 4, PHP 5, PHP 7, PHP 8)
quotemeta — 转义元字符集
说明
quotemeta(string$str): string返回 在下面这些特殊字符前加 反斜线(
\) 转义后的字符串。 这些特殊字符包含:. \ + * ? [ ^ ] ( $ )参数
-
str -
输入字符串
返回值
返回 元字符集被转义后的 字符串,如果输入字符串
str为空, 则返回false。注释
注意: 此函数可安全用于二进制对象。
参见
- addslashes() - 使用反斜线引用字符串
- addcslashes() - 以 C 语言风格使用反斜线转义字符串中的字符
- htmlentities() - 将字符转换为 HTML 转义字符
- htmlspecialchars() - 将特殊字符转换为 HTML 实体
- nl2br() - 在字符串所有新行之前插入 HTML 换行标记
- stripslashes() - 反引用一个引用字符串
- stripcslashes() - 反引用一个使用 addcslashes 转义的字符串
- ereg()
- preg_quote() - 转义正则表达式字符
-
- 前端开发(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号