💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# PHP String 函数 ## PHP String 简介 String 字符串函数允许您对字符串进行操作。 ## 安装 String 函数是 PHP 核心的组成部分。无需安装即可使用这些函数。 ## PHP String 函数 PHP:指示支持该函数的最早的 PHP 版本。 | 函数 | 描述 | PHP | | --- | --- | --- | | [addcslashes()](func_string_addcslashes.asp) | 在指定的字符前添加反斜杠。 | 4 | | [addslashes()](func_string_addslashes.asp) | 在指定的预定义字符前添加反斜杠。 | 3 | | [bin2hex()](func_string_bin2hex.asp) | 把 ASCII 字符的字符串转换为十六进制值。 | 3 | | [chop()](func_string_chop.asp) | rtrim() 的别名。 | 3 | | [chr()](func_string_chr.asp) | 从指定的 ASCII 值返回字符。 | 3 | | [chunk_split()](func_string_chunk_split.asp) | 把字符串分割为一连串更小的部分。 | 3 | | [convert_cyr_string()](func_string_convert_cyr_string.asp) | 把字符由一种 Cyrillic 字符转换成另一种。 | 3 | | [convert_uudecode()](func_string_convert_uudecode.asp) | 对 uuencode 编码的字符串进行解码。 | 5 | | [convert_uuencode()](func_string_convert_uuencode.asp) | 使用 uuencode 算法对字符串进行编码。 | 5 | | [count_chars()](func_string_count_chars.asp) | 返回字符串所用字符的信息。 | 4 | | [crc32()](func_string_crc32.asp) | 计算一个字符串的 32-bit CRC。 | 4 | | [crypt()](func_string_crypt.asp) | 单向的字符串加密法 (hashing)。 | 3 | | [echo()](func_string_echo.asp) | 输出字符串。 | 3 | | [explode()](func_string_explode.asp) | 把字符串打散为数组。 | 3 | | [fprintf()](func_string_fprintf.asp) | 把格式化的字符串写到指定的输出流。 | 5 | | [get_html_translation_table()](func_string_get_html_translation_table.asp) | 返回翻译表。 | 4 | | [hebrev()](func_string_hebrev.asp) | 把希伯来文本从右至左的流转换为左至右的流。 | 3 | | [hebrevc()](func_string_hebrevc.asp) | 同上,同时把(\n) 转为 <br />。 | 3 | | [html_entity_decode()](func_string_html_entity_decode.asp) | 把 HTML 实体转换为字符。 | 4 | | [htmlentities()](func_string_htmlentities.asp) | 把字符转换为 HTML 实体。 | 3 | | [htmlspecialchars_decode()](func_string_htmlspecialchars_decode.asp) | 把一些预定义的 HTML 实体转换为字符。 | 5 | | [htmlspecialchars()](func_string_htmlspecialchars.asp) | 把一些预定义的字符转换为 HTML 实体。 | 3 | | [implode()](func_string_implode.asp) | 把数组元素组合为一个字符串。 | 3 | | [join()](func_string_join.asp) | implode() 的别名。 | 3 | | [levenshtein()](func_string_levenshtein.asp) | 返回两个字符串之间的 Levenshtein 距离。 | 3 | | [localeconv()](func_string_localeconv.asp) | 返回包含本地数字及货币信息格式的数组。 | 4 | | [ltrim()](func_string_ltrim.asp) | 从字符串左侧删除空格或其他预定义字符。 | 3 | | [md5()](func_string_md5.asp) | 计算字符串的 MD5 散列。 | 3 | | [md5_file()](func_string_md5_file.asp) | 计算文件的 MD5 散列。 | 4 | | [metaphone()](func_string_metaphone.asp) | 计算字符串的 metaphone 键。 | 4 | | [money_format()](func_string_money_format.asp) | 把字符串格式化为货币字符串。 | 4 | | [nl_langinfo()](func_string_nl_langinfo.asp) | 返回指定的本地信息。 | 4 | | [nl2br()](func_string_nl2br.asp) | 在字符串中的每个新行之前插入 HTML 换行符。 | 3 | | [number_format()](func_string_number_format.asp) | 通过千位分组来格式化数字。 | 3 | | [ord()](func_string_ord.asp) | 返回字符串第一个字符的 ASCII 值。 | 3 | | [parse_str()](func_string_parse_str.asp) | 把查询字符串解析到变量中。 | 3 | | [print()](func_string_print.asp) | 输出一个或多个字符串。 | 3 | | [printf()](func_string_printf.asp) | 输出格式化的字符串。 | 3 | | [quoted_printable_decode()](func_string_quoted_printable_decode.asp) | 解码 quoted-printable 字符串。 | 3 | | [quotemeta()](func_string_quotemeta.asp) | 在字符串中某些预定义的字符前添加反斜杠。 | 3 | | [rtrim()](func_string_rtrim.asp) | 从字符串的末端开始删除空白字符或其他预定义字符。 | 3 | | [setlocale()](func_string_setlocale.asp) | 设置地区信息(地域信息)。 | 3 | | [sha1()](func_string_sha1.asp) | 计算字符串的 SHA-1 散列。 | 4 | | [sha1_file()](func_string_sha1_file.asp) | 计算文件的 SHA-1 散列。 | 4 | | [similar_text()](func_string_similar_text.asp) | 计算两个字符串的匹配字符的数目。 | 3 | | [soundex()](func_string_soundex.asp) | 计算字符串的 soundex 键。 | 3 | | [sprintf()](func_string_sprintf.asp) | 把格式化的字符串写写入一个变量中。 | 3 | | [sscanf()](func_string_sscanf.asp) | 根据指定的格式解析来自一个字符串的输入。 | 4 | | [str_ireplace()](func_string_str_ireplace.asp) | 替换字符串中的一些字符。(对大小写不敏感) | 5 | | [str_pad()](func_string_str_pad.asp) | 把字符串填充为新的长度。 | 4 | | [str_repeat()](func_string_str_repeat.asp) | 把字符串重复指定的次数。 | 4 | | [str_replace()](func_string_str_replace.asp) | 替换字符串中的一些字符。(对大小写敏感) | 3 | | [str_rot13()](func_string_str_rot13.asp) | 对字符串执行 ROT13 编码。 | 4 | | [str_shuffle()](func_string_str_shuffle.asp) | 随机地打乱字符串中的所有字符。 | 4 | | [str_split()](func_string_str_split.asp) | 把字符串分割到数组中。 | 5 | | [str_word_count()](func_string_str_word_count.asp) | 计算字符串中的单词数。 | 4 | | [strcasecmp()](func_string_strcasecmp.asp) | 比较两个字符串。(对大小写不敏感) | 3 | | [strchr()](func_string_strchr.asp) | 搜索字符串在另一字符串中的第一次出现。strstr() 的别名 | 3 | | [strcmp()](func_string_strcmp.asp) | 比较两个字符串。(对大小写敏感) | 3 | | [strcoll()](func_string_strcoll.asp) | 比较两个字符串(根据本地设置)。 | 4 | | [strcspn()](func_string_strcspn.asp) | 返回在找到任何指定的字符之前,在字符串查找的字符数。 | 3 | | [strip_tags()](func_string_strip_tags.asp) | 剥去 HTML、XML 以及 PHP 的标签。 | 3 | | [stripcslashes()](func_string_stripcslashes.asp) | 删除由 addcslashes() 函数添加的反斜杠。 | 4 | | [stripslashes()](func_string_stripslashes.asp) | 删除由 addslashes() 函数添加的反斜杠。 | 3 | | [stripos()](func_string_stripos.asp) | 返回字符串在另一字符串中第一次出现的位置(大小写不敏感) | 5 | | [stristr()](func_string_stristr.asp) | 查找字符串在另一字符串中第一次出现的位置(大小写不敏感) | 3 | | [strlen()](func_string_strlen.asp) | 返回字符串的长度。 | 3 | | [strnatcasecmp()](func_string_strnatcasecmp.asp) | 使用一种“自然”算法来比较两个字符串(对大小写不敏感) | 4 | | [strnatcmp()](func_string_strnatcmp.asp) | 使用一种“自然”算法来比较两个字符串(对大小写敏感) | 4 | | [strncasecmp()](func_string_strncasecmp.asp) | 前 n 个字符的字符串比较(对大小写不敏感)。 | 4 | | [strncmp()](func_string_strncmp.asp) | 前 n 个字符的字符串比较(对大小写敏感)。 | 4 | | [strpbrk()](func_string_strpbrk.asp) | 在字符串中搜索指定字符中的任意一个。 | 5 | | [strpos()](func_string_strpos.asp) | 返回字符串在另一字符串中首次出现的位置(对大小写敏感) | 3 | | [strrchr()](func_string_strrchr.asp) | 查找字符串在另一个字符串中最后一次出现的位置。 | 3 | | [strrev()](func_string_strrev.asp) | 反转字符串。 | 3 | | [strripos()](func_string_strripos.asp) | 查找字符串在另一字符串中最后出现的位置(对大小写不敏感) | 5 | | [strrpos()](func_string_strrpos.asp) | 查找字符串在另一字符串中最后出现的位置(对大小写敏感) | 3 | | [strspn()](func_string_strspn.asp) | 返回在字符串中包含的特定字符的数目。 | 3 | | [strstr()](func_string_strstr.asp) | 搜索字符串在另一字符串中的首次出现(对大小写敏感) | 3 | | [strtok()](func_string_strtok.asp) | 把字符串分割为更小的字符串。 | 3 | | [strtolower()](func_string_strtolower.asp) | 把字符串转换为小写。 | 3 | | [strtoupper()](func_string_strtoupper.asp) | 把字符串转换为大写。 | 3 | | [strtr()](func_string_strtr.asp) | 转换字符串中特定的字符。 | 3 | | [substr()](func_string_substr.asp) | 返回字符串的一部分。 | 3 | | [substr_compare()](func_string_substr_compare.asp) | 从指定的开始长度比较两个字符串。 | 5 | | [substr_count()](func_string_substr_count.asp) | 计算子串在字符串中出现的次数。 | 4 | | [substr_replace()](func_string_substr_replace.asp) | 把字符串的一部分替换为另一个字符串。 | 4 | | [trim()](func_string_trim.asp) | 从字符串的两端删除空白字符和其他预定义字符。 | 3 | | [ucfirst()](func_string_ucfirst.asp) | 把字符串中的首字符转换为大写。 | 3 | | [ucwords()](func_string_ucwords.asp) | 把字符串中每个单词的首字符转换为大写。 | 3 | | [vfprintf()](func_string_vfprintf.asp) | 把格式化的字符串写到指定的输出流。 | 5 | | [vprintf()](func_string_vprintf.asp) | 输出格式化的字符串。 | 4 | | [vsprintf()](func_string_vsprintf.asp) | 把格式化字符串写入变量中。 | 4 | | [wordwrap()](func_string_wordwrap.asp) | 按照指定长度对字符串进行折行处理。 | 4 | ## PHP String 常量 PHP:指示支持该常量的最早的 PHP 版本。 | 常量 | 描述 | PHP | | --- | --- | --- | | CRYPT_SALT_LENGTH | 包含系统默认加密方法的长度。对于标准 DES 加密,长度是 2。 | | CRYPT_STD_DES | 如果支持 2 字符 salt 的 DES 加密,则设置为 1,否则为 0。 | | CRYPT_EXT_DES | 如果支持 9 字符 salt 的 DES 加密,则设置为 1,否则为 0。 | | CRYPT_MD5 | 如果支持以$1$开始的 12 字符 salt 的MD5加密,则设置为1,否则为0。 | | CRYPT_BLOWFISH | 如果支持以 $2$ 或 $2a$ 开始的 16 字符 salt 的 Blowfish 加密,则设置为 1,否则为 0。 | | HTML_SPECIALCHARS | | HTML_ENTITIES | | ENT_COMPAT | | ENT_QUOTES | | ENT_NOQUOTES | | CHAR_MAX | | LC_CTYPE | | LC_NUMERIC | | LC_TIME | | LC_COLLATE | | LC_MONETARY | | LC_ALL | | LC_MESSAGES | | STR_PAD_LEFT | | STR_PAD_RIGHT | | STR_PAD_BOTH |