当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP String

PHP
PHP 介绍
PHP 安装
PHP 语法
PHP 变量
PHP操作符
PHP If...Else
PHP Switch
PHP 数组
PHP 循环
PHP 函数
PHP 表单
PHP $_GET
PHP $_POST
PHP Date
PHP Include
PHP 文件处理
PHP 文件上传
PHP Cookies
PHP Sessions
PHP 发送邮件

PHP String


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 879 ::
收藏到网摘: n/a

PHP String Introduction
PHP字符串介绍

The string functions allow you to manipulate strings.
本类函数用来对字符串进行各种操作。


Installation
安装

The string functions are part of the PHP core. There is no installation needed to use these functions.
本函数库作为 PHP 内核的一部分,不用安装就能使用。


PHP String Functions
PHP字符串函数

PHP: indicates the earliest version of PHP that supports the function.
PHP:最早支持这些函数的PHP版本

Function函数 Description说明 PHP
addcslashes() Returns a string with backslashes in front of the specified characters
像 C 那样使用反斜线转义字符串中的字符
4
addslashes() Returns a string with backslashes in front of predefined characters
使用反斜线引用字符串
3
bin2hex() Converts a string of ASCII characters to hexadecimal values
将二进制数据转换成十六进制表示
3
chop() Alias of rtrim()
rtrim() 的别名函数
3
chr() Returns a character from a specified ASCII value
返回指定的字符
3
chunk_split() Splits a string into a series of smaller parts
将字符串分割成小块
3
convert_cyr_string() Converts a string from one Cyrillic character-set to another
将字符由一种 Cyrillic 字符转换成另一种
3
convert_uudecode() Decodes a uuencoded string
对用uuencode算法编码的字符串解码
5
convert_uuencode() Encodes a string using the uuencode algorithm
用uuencode算法对字符串编码
5
count_chars() Returns how many times an ASCII character occurs within a string and returns the information
返回字符串所用字符的信息
4
crc32() Calculates a 32-bit CRC for a string
计算一个字符串的 crc32 多项式
4
crypt() One-way string encryption (hashing)
不可逆加密(散列)
3
echo() Outputs strings
输出字符串
3
explode() Breaks a string into an array
使用一个字符串分割另一个字符串
3
fprintf() Writes a formatted string to a specified output stream
输出格式化字符串到流
将格式化后的字符串写到输出流
5
get_html_translation_table() Returns the translation table used by htmlspecialchars() and htmlentities()
返回htmlspecialchars()和htmlentities()的转换表
4
hebrev() Converts Hebrew text to visual text
转换希伯来语文本为可见文本
3
hebrevc() Converts Hebrew text to visual text and new lines (n) into <br />
转换希伯来语文本为可见文本,换行 (n) 为 <br />
3
html_entity_decode() Converts HTML entities to characters
转换HTML字符编码为字符
4
htmlentities() Converts characters to HTML entities
转换字符为HTML字符编码
3
htmlspecialchars_decode() Converts some predefined HTML entities to characters
转换特殊HTML字符编码为字符
5
htmlspecialchars() Converts some predefined characters to HTML entities
转换特殊字符为HTML字符编码
3
implode() Returns a string from the elements of an array
将数组元素组合为字符串输出
3
join() Alias of implode()
别名 implode()
3
levenshtein() Returns the Levenshtein distance between two strings
计算两个字符串的Levenshtein距离
3
localeconv() Returns locale numeric and monetary formatting information
返回当地的数字和货币格式信息
4
ltrim() Strips whitespace from the left side of a string
去除字符串左端的空白(或其它字符)
3
md5() Calculates the MD5 hash of a string
计算字符串的MD5 hash
3
md5_file() Calculates the MD5 hash of a file
计算文件的MD5 hash
4
metaphone() Calculates the metaphone key of a string
计算字符串的metaphone 键
4
money_format() Returns a string formatted as a currency string
将数字格式化为货币形式
4
nl_langinfo() Returns specific local information
获取语言及本地信息
4
nl2br() Inserts HTML line breaks in front of each newline in a string
在字符串的每个新行前插入HTML换行标志
3
number_format() Formats a number with grouped thousands
用千位分隔符号格式化数字
3
ord() Returns the ASCII value of the first character of a string
返回字符串中首字符的ASCII码值
3
parse_str() Parses a query string into variables
将字串符解析为变量
3
print() Outputs a string
输出字符串
3
printf() Outputs a formatted string
输出格式化字符串
3
quoted_printable_decode() Decodes a quoted-printable string
转换quoted-printable字符串为8位字符串
3
quotemeta() Quotes meta characters
转义字符串中的meta字符
3
rtrim()

Strips whitespace from the right side of a string
去除字符串末尾的空白(或其它字符)

3
setlocale() Sets locale information
设置本化信息
3
sha1() Calculates the SHA-1 hash of a string
计算字符串的SHA-1 hash
4
sha1_file() Calculates the SHA-1 hash of a file
计算文件的SHA-1 hash
4
similar_text() Calculates the similarity between two strings
计算两个字符串的相似性
3
soundex() Calculates the soundex key of a string
计算字符串的soundx key
3
sprintf() Writes a formatted string to a variable
输出格式化字符串到变量
3
sscanf() Parses input from a string according to a format
按照一定格式解析输入的字符串
4
str_ireplace() Replaces some characters in a string (case-insensitive)
大小写不敏感的str_replace().
5
str_pad() Pads a string to a new length
用一个字符串填充另一个字符串到指定长度
4
str_repeat() Repeats a string a specified number of times
重复字符串
4
str_replace() Replaces some characters in a string (case-sensitive)
将某个子字符串都替换为另一个字符串(大小写敏感)
3
str_rot13() Performs the ROT13 encoding on a string
对字符串作ROT13编码
4
str_shuffle() Randomly shuffles all characters in a string
随机打乱字符串中的字符顺序
4
str_split() Splits a string into an array
转换字符串为数组
5
str_word_count() Count the number of words in a string
计算字符串中的词数
4
strcasecmp() Compares two strings (case-insensitive)
比较两个字符串(大小写不敏感)
3
strchr() Finds the first occurrence of a string inside another string (alias of strstr())
别名 strstr()
3
strcmp() Compares two strings (case-sensitive)
比较两个字符串(大小写敏感)
3
strcoll() Locale based string comparison
基于本地的字符串比较
4
strcspn() Returns the number of characters found in a string before any part of some specified characters are found
返回字符串中起首不符合mask的子字符串长度
3
strip_tags() Strips HTML and PHP tags from a string
除去字符串中的HTML和PHP标签
3
stripcslashes() Unquotes a string quoted with addcslashes()
将用addcslashes()处理后的字符串返回原样
4
stripslashes() Unquotes a string quoted with addslashes()
将用addslashes()处理后的字符串返回原样
3
stripos() Returns the position of the first occurrence of a string inside another string (case-insensitive)
查找一个字符串在另一个字符串中首次出现的位置(大小写不敏感)
5
stristr() Finds the first occurrence of a string inside another string (case-insensitive)
大小写不敏感的strstr()
3
strlen() Returns the length of a string
字符串长度
3
strnatcasecmp() Compares two strings using a "natural order" algorithm (case-insensitive)
用natural order算法比较字符串(大小写不敏感)
4
strnatcmp() Compares two strings using a "natural order" algorithm (case-sensitive)
用natural order算法比较字符串(大小写敏感)
4
strncasecmp() String comparison of the first n characters (case-insensitive)
比较字符串的前n个字符(大小写不敏感)
4
strncmp() String comparison of the first n characters (case-sensitive)
比较字符串的前n个字符(大小写敏感)
4
strpbrk() Searches a string for any of a set of characters
查找字符串中的一系列字符
5
strpos() Returns the position of the first occurrence of a string inside another string (case-sensitive)
查找一个字符串在另一个字符串中首次出现的位置(大小写敏感)
3
strrchr() Finds the last occurrence of a string inside another string
查找一个字符串在另一个字符串中末次出现的位置
3
strrev() Reverses a string
倒转字符串
3
strripos() Finds the position of the last occurrence of a string inside another string (case-insensitive)
查找一个字符串在另一个字符串中末次出现的位置(大小写不敏感)
5
strrpos() Finds the position of the last occurrence of a string inside another string (case-sensitive)
查找一个字符串在另一个字符串中末次出现的位置(大小写敏感)
3
strspn() Returns the number of characters found in a string that contains only characters from a specified charlist
返回字符串中起首符合mask的子字符串长度
3
strstr() Finds the first occurrence of a string inside another string (case-sensitive)
返回一个字符串在另一个字符串中首次出现的位置到后者末尾的子字符串(大小写敏感)
3
strtok() Splits a string into smaller strings
将字符串分割成小块
3
strtolower() Converts a string to lowercase letters
转为小写字母
3
strtoupper() Converts a string to uppercase letters
转为大写字母
3
strtr() Translates certain characters in a string
转换字串中一些字母
3
substr() Returns a part of a string
返回子字串
3
substr_compare() Compares two strings from a specified start position (binary safe and optionally case-sensitive)
从一定起始位置在一定长度内比较两个字串符(二进制精确,大小写敏感可选)
5
substr_count() Counts the number of times a substring occurs in a string
查找子字符串出现次数
4
substr_replace() Replaces a part of a string with another string
替换字符串中一部分为另一字符串
4
trim() Strips whitespace from both sides of a string
去除字符串首末尾的空白(或其它字符)
3
ucfirst() Converts the first character of a string to uppercase
字符串首字母大写
3
ucwords() Converts the first character of each word in a string to uppercase
字符串中每个词的首字母大写
3
vfprintf() Writes a formatted string to a specified output stream
输出格式化字符串到流
5
vprintf() Outputs a formatted string
输出格式化字符串
4
vsprintf() Writes a formatted string to a variable
输出格式化字符串到变量
4
wordwrap() Wraps a string to a given number of characters
将字符串按字符个数换行
4


PHP String Constants
PHP字符串常量

PHP: indicates the earliest version of PHP that supports the constant.
PHP:最早支持这些常量的PHP版本

Constant常量 Description说明 PHP
CRYPT_SALT_LENGTH Contains the length of the default encryption method for the
system. For standard DES encryption, the length is 2
包含系统使用的默认加密编码长度。默认长度为2
 
CRYPT_STD_DES Set to 1 if the standard DES-based encryption with a 2 character salt is supported, 0 otherwise
如果支持基于DES的2位字符加密编码,那么该常量设置为1;否则设置为0
 
CRYPT_EXT_DES Set to 1 if the extended DES-based encryption with a 9 character salt is supported, 0 otherwise
如果支持基于DES的9位字符加密编码,那么该常量设置为1;否则设置为0
 
CRYPT_MD5

Set to 1 if the MD5 encryption with a 12 character salt starting with $1$ is supported, 0 otherwise
如果支持MD5的12位字符加密编码,并且该加密编码以 $1$ 起始,则将该常量设置为1;否则设置为0

 
CRYPT_BLOWFISH Set to 1 if the Blowfish encryption with a 16 character salt starting with $2$ or $2a$ is supported, 0 otherwise0
如果支持Blowfish的16位字符加密编码,并且该加密编码以 $2$ 或$2a$起始,则将该常量设置为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    

评论 (0) All

登陆 | 还没注册?