本文目录一览:
- 1、求字符串处理函数(全)
- 2、函数把包含数据的二进制字符串转换为十六进制值?
- 3、PHP中bin2hex()返回值为什么不是以0x开头的?
- 4、C语言程序: 将二进制转换成十进制
- 5、求将十进制数转为十六进制数的JS或PHP代码
- 6、PHP符串处理函数
求字符串处理函数(全)
函数名: stpcpy
功 能: 拷贝一个字符串到另一个
用 法: char *stpcpy(char *destin, char *source);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
stpcpy(string, str1);
printf("%sn", string);
return 0;
}
函数名: strcat
功 能: 字符串拼接函数
用 法: char *strcat(char *destin, char *source);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char destination[25];
char *blank = " ", *c = "C++", *Borland = "Borland";
strcpy(destination, Borland);
strcat(destination, blank);
strcat(destination, c);
printf("%sn", destination);
return 0;
}
函数名: strchr
功 能: 在一个串中查找给定字符的第一个匹配之处
用 法: char *strchr(char *str, char c);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char string[15];
char *ptr, c = 'r';
strcpy(string, "This is a string");
ptr = strchr(string, c);
if (ptr)
printf("The character %c is at position: %dn", c, ptr-string);
else
printf("The character was not foundn");
return 0;
}
函数名: strcmp
功 能: 串比较
用 法: int strcmp(char *str1, char *str2);
看Asic码,str1str2,返回值 0;两串相等,返回0
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "aaa", *buf2 = "bbb", *buf3 = "ccc";
int ptr;
ptr = strcmp(buf2, buf1);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
else
printf("buffer 2 is less than buffer 1n");
ptr = strcmp(buf2, buf3);
if (ptr 0)
printf("buffer 2 is greater than buffer 3n");
else
printf("buffer 2 is less than buffer 3n");
return 0;
}
函数名: strncmpi
功 能: 将一个串中的一部分与另一个串比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2, unsigned maxlen);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = strcmpi(buf2, buf1);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
if (ptr 0)
printf("buffer 2 is less than buffer 1n");
if (ptr == 0)
printf("buffer 2 equals buffer 1n");
return 0;
}
函数名: strcpy
功 能: 串拷贝
用 法: char *strcpy(char *str1, char *str2);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
strcpy(string, str1);
printf("%sn", string);
return 0;
}
函数名: strcspn
功 能: 在串中查找第一个给定字符集内容的段
用 法: int strcspn(char *str1, char *str2);
程序例:
#include stdio.h
#include string.h
#include alloc.h
int main(void)
{
char *string1 = "1234567890";
char *string2 = "747DC8";
int length;
length = strcspn(string1, string2);
printf("Character where strings intersect is at position %dn", length);
return 0;
}
函数名: strdup
功 能: 将串拷贝到新建的位置处
用 法: char *strdup(char *str);
程序例:
#include stdio.h
#include string.h
#include alloc.h
int main(void)
{
char *dup_str, *string = "abcde";
dup_str = strdup(string);
printf("%sn", dup_str);
free(dup_str);
return 0;
}
函数名: stricmp
功 能: 以大小写不敏感方式比较两个串
用 法: int stricmp(char *str1, char *str2);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = stricmp(buf2, buf1);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
if (ptr 0)
printf("buffer 2 is less than buffer 1n");
if (ptr == 0)
printf("buffer 2 equals buffer 1n");
return 0;
}
函数名: strerror
功 能: 返回指向错误信息字符串的指针
用 法: char *strerror(int errnum);
程序例:
#include stdio.h
#include errno.h
int main(void)
{
char *buffer;
buffer = strerror(errno);
printf("Error: %sn", buffer);
return 0;
}
函数名: strcmpi
功 能: 将一个串与另一个比较, 不管大小写
用 法: int strcmpi(char *str1, char *str2);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "BBB", *buf2 = "bbb";
int ptr;
ptr = strcmpi(buf2, buf1);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
if (ptr 0)
printf("buffer 2 is less than buffer 1n");
if (ptr == 0)
printf("buffer 2 equals buffer 1n");
return 0;
}
函数名: strncmp
功 能: 串比较
用 法: int strncmp(char *str1, char *str2, int maxlen);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "aaabbb", *buf2 = "bbbccc", *buf3 = "ccc";
int ptr;
ptr = strncmp(buf2,buf1,3);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
else
printf("buffer 2 is less than buffer 1n");
ptr = strncmp(buf2,buf3,3);
if (ptr 0)
printf("buffer 2 is greater than buffer 3n");
else
printf("buffer 2 is less than buffer 3n");
return(0);
}
函数名: strncmpi
功 能: 把串中的一部分与另一串中的一部分比较, 不管大小写
用 法: int strncmpi(char *str1, char *str2);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strncmpi(buf2,buf1,3);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
if (ptr 0)
printf("buffer 2 is less than buffer 1n");
if (ptr == 0)
printf("buffer 2 equals buffer 1n");
return 0;
}
函数名: strncpy
功 能: 串拷贝
用 法: char *strncpy(char *destin, char *source, int maxlen);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
strncpy(string, str1, 3);
string[3] = '';
printf("%sn", string);
return 0;
}
函数名: strnicmp
功 能: 不注重大小写地比较两个串
用 法: int strnicmp(char *str1, char *str2, unsigned maxlen);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strnicmp(buf2, buf1, 3);
if (ptr 0)
printf("buffer 2 is greater than buffer 1n");
if (ptr 0)
printf("buffer 2 is less than buffer 1n");
if (ptr == 0)
printf("buffer 2 equals buffer 1n");
return 0;
}
函数名: strnset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strnset(char *str, char ch, unsigned n);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';
printf("string before strnset: %sn", string);
strnset(string, letter, 13);
printf("string after strnset: %sn", string);
return 0;
}
函数名: strpbrk
功 能: 在串中查找给定字符集中的字符
用 法: char *strpbrk(char *str1, char *str2);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char *string1 = "abcdefghijklmnopqrstuvwxyz";
char *string2 = "onm";
char *ptr;
ptr = strpbrk(string1, string2);
if (ptr)
printf("strpbrk found first character: %cn", *ptr);
else
printf("strpbrk didn't find character in setn");
return 0;
}
函数名: strrchr
功 能: 在串中查找指定字符的最后一个出现
用 法: char *strrchr(char *str, char c);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char string[15];
char *ptr, c = 'r';
strcpy(string, "This is a string");
ptr = strrchr(string, c);
if (ptr)
printf("The character %c is at position: %dn", c, ptr-string);
else
printf("The character was not foundn");
return 0;
}
函数名: strrev
功 能: 串倒转
用 法: char *strrev(char *str);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char *forward = "string";
printf("Before strrev(): %sn", forward);
strrev(forward);
printf("After strrev(): %sn", forward);
return 0;
}
函数名: strset
功 能: 将一个串中的所有字符都设为指定字符
用 法: char *strset(char *str, char c);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char string[10] = "123456789";
char symbol = 'c';
printf("Before strset(): %sn", string);
strset(string, symbol);
printf("After strset(): %sn", string);
return 0;
}
函数名: strspn
功 能: 在串中查找指定字符集的子集的第一次出现
用 法: int strspn(char *str1, char *str2);
程序例:
#include stdio.h
#include string.h
#include alloc.h
int main(void)
{
char *string1 = "1234567890";
char *string2 = "123DC8";
int length;
length = strspn(string1, string2);
printf("Character where strings differ is at position %dn", length);
return 0;
}
函数名: strstr
功 能: 在串中查找指定字符串的第一次出现
用 法: char *strstr(char *str1, char *str2);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char *str1 = "Borland International", *str2 = "nation", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %sn", ptr);
return 0;
}
函数名: strtod
功 能: 将字符串转换为double型值
用 法: double strtod(char *str, char **endptr);
程序例:
#include stdio.h
#include stdlib.h
int main(void)
{
char input[80], *endptr;
double value;
printf("Enter a floating point number:");
gets(input);
value = strtod(input, endptr);
printf("The string is %s the number is %lfn", input, value);
return 0;
}
函数名: strtok
功 能: 查找由在第二个串中指定的分界符分隔开的单词
用 法: char *strtok(char *str1, char *str2);
程序例:
#include string.h
#include stdio.h
int main(void)
{
char input[16] = "abc,d";
char *p;
/* strtok places a NULL terminator
in front of the token, if found */
p = strtok(input, ",");
if (p) printf("%sn", p);
/* A second call to strtok using a NULL
as the first parameter returns a pointer
to the character following the token */
p = strtok(NULL, ",");
if (p) printf("%sn", p);
return 0;
}
函数名: strtol
功 能: 将串转换为长整数
用 法: long strtol(char *str, char **endptr, int base);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
char *string = "87654321", *endptr;
long lnumber;
/* strtol converts string to long integer */
lnumber = strtol(string, endptr, 10);
printf("string = %s long = %ldn", string, lnumber);
return 0;
}
函数名: strupr
功 能: 将串中的小写字母转换为大写字母
用 法: char *strupr(char *str);
程序例:
#include stdio.h
#include string.h
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz", *ptr;
/* converts string to upper case characters */
ptr = strupr(string);
printf("%sn", ptr);
return 0;
}
函数名: swab
功 能: 交换字节
用 法: void swab (char *from, char *to, int nbytes);
程序例:
#include stdlib.h
#include stdio.h
#include string.h
char source[15] = "rFna koBlrna d";
char target[15];
int main(void)
{
swab(source, target, strlen(source));
printf("This is target: %sn", target);
return 0;
}
PS:isalpha()是字符函数,不是字符串函数,
isalpha
原型:extern int isalpha(int c);
用法:#include ctype.h
功能:判断字符c是否为英文字母
说明:当c为英文字母a-z或A-Z时,返回非零值,否则返回零。
举例:
// isalpha.c
#include syslib.h
#include ctype.h
#include stdio.h
main()
{
int c;
clrscr(); // clear screen
printf("Press a key");
for(;;)
{
c=getchar();
clrscr();
printf("%c: %s letter",c,isalpha(c)?"is":"not");
}
return 0; // just to avoid warnings by compiler
}
函数把包含数据的二进制字符串转换为十六进制值?
bin2hex
(PHP 4, PHP 5, PHP 7, PHP 8)
bin2hex — 函数把包含数据的二进制字符串转换为十六进制值
说明
bin2hex ( string $str ) : string
把二进制的参数 str 转换为的十六进制的字符串。转换使用字节方式,高四位字节优先。
参数
str
二进制字符串。
返回值
返回指定字符串十六进制的表示。
参见
hex2bin() - 转换十六进制字符串为二进制字符串
pack() - 将数据打包成二进制字符串
add a note add a note
User Contributed Notes 23 notes
47 tehjosh at gamingg dot net ¶13 years ago
This function is for converting binary data into a hexadecimal string representation. This function is not for converting strings representing binary digits into hexadecimal. If you want that functionality, you can simply do this:
This would output "f9". Just remember that there is a very big difference between binary data and a string representation of binary.
PHP中bin2hex()返回值为什么不是以0x开头的?
众口难调呀,系统如果输出了0x,不需要的时候又要去删除它,相对来说删除比添加更麻烦。
你如果需要在添加0x,可以参考下面这样的代码:
?php
$str=bin2hex("shanghai");
$str=preg_replace('/(..)/','0x$1',$str);
echo $str;
?
C语言程序: 将二进制转换成十进制
根据要求中的限制,可以直接利用接收字符函数即可实现。代码如下,输入的是0或者1,那么一直转换;直到输入不是0或者1,退出程序。可以直接拷贝,验证正确:
#includestdio.h
#includestdlib.h
int main()
{
char ch;
unsigned int num;
while( 1 )//一直循环
{
num = 0;
while( (ch = getchar()) != '/n' )
{
if ('0' = ch ch = '1')
num = (num 1) + ch - '0';
else
exit(1);//如果输入的不是0或者1,那么退出程序
}
printf("0x%X/n", num);
}
}
求将十进制数转为十六进制数的JS或PHP代码
JS十进制转其他进制代码如下var m = 10;document.write(m.toString(2) + "br"); // 显示为 1010 二进制document.write(m.toString(8) + "br"); // 显示为 12 8进制document.write(m.toString(10) + "br"); // 显示为 10 十进制document.write(m.toString(16) + "br"); // 显示为 a, 十六进制 php转换函数如下:bindec() — 二进制转换为十进制
decbin() — 十进制转换为二进制
dechex() — 十进制转换为十六进制
decoct() — 十进制转换为八进制
hexdec() — 十六进制转换为十进制
octdec() — 八进制转换为十进制
base_convert()– 在任意进制之间转换数字使用说明如下: 一,十进制(decimal system)转换函数说明
1,十进制转二进制 decbin() 函数,如下实例echo decbin(12); //输出 1100
echo decbin(26); //输出 11010
decbin
(PHP 3, PHP 4, PHP 5)
decbin -- 十进制转换为二进制
说明
string decbin ( int number )
返回一字符串,包含有给定 number 参数的二进制表示。所能转换的最大数值为十进制的 4294967295,其结果为 32 个 1 的字符串。2,十进制转八进制 decoct() 函数echo decoct(15); //输出 17
echo decoct(264); //输出 410
decoct
(PHP 3, PHP 4, PHP 5)
decoct -- 十进制转换为八进制
说明
string decoct ( int number )
返回一字符串,包含有给定 number 参数的八进制表示。所能转换的最大数值为十进制的 4294967295,其结果为 "37777777777"。3,十进制转十六进制 dechex() 函数echo dechex(10); //输出 a
echo dechex(47); //输出 2f
dechex
(PHP 3, PHP 4, PHP 5)
dechex -- 十进制转换为十六进制
说明
string dechex ( int number )
返回一字符串,包含有给定 number 参数的十六进制表示。所能转换的最大数值为十进制的 4294967295,其结果为 "ffffffff"。二,二进制(binary system)转换函数说明
1,二进制转十六制进 bin2hex() 函数$binary = "11111001";
$hex = dechex(bindec($binary));
echo $hex;//输出f9
bin2hex
(PHP 3 = 3.0.9, PHP 4, PHP 5)
bin2hex -- 将二进制数据转换成十六进制表示
说明
string bin2hex ( string str )
返回 ASCII 字符串,为参数 str 的十六进制表示。转换使用字节方式,高四位字节优先。2,二进制转十制进 bindec() 函数echo bindec(///'110011///'); //输出 51
echo bindec(///'000110011///'); //输出 51
echo bindec(///'111///'); //输出 7
bindec
(PHP 3, PHP 4, PHP 5)
bindec -- 二进制转换为十进制
说明
number bindec ( string binary_string )
返回 binary_string 参数所表示的二进制数的十进制等价值。
bindec() 将一个二进制数转换成 integer。可转换的最大的数为 31 位 1 或者说十进制的 2147483647。PHP 4.1.0 开始,该函数可以处理大数值,这种情况下,它会返回 float 类型。三,八进制(octal system)转换函数说明
八进制转十进制 octdec() 函数echo octdec(///'77///'); //输出 63
echo octdec(decoct(45)); //输出 45
octdec
(PHP 3, PHP 4, PHP 5)
octdec -- 八进制转换为十进制
说明
number octdec ( string octal_string )
返回 octal_string 参数所表示的八进制数的十进制等值。可转换的最大的数值为 17777777777 或十进制的 2147483647。PHP 4.1.0 开始,该函数可以处理大数字,这种情况下,它会返回 float 类型。四,十六进制(hexadecimal)转换函数说明
十六进制转十进制 hexdec()函数var_dump(hexdec("See"));
var_dump(hexdec("ee"));
// both print "int(238)"
var_dump(hexdec("that")); // print "int(10)"
var_dump(hexdec("a0")); // print "int(160)"
hexdec
(PHP 3, PHP 4, PHP 5)
hexdec -- 十六进制转换为十进制
说明
number hexdec ( string hex_string )
返回与 hex_string 参数所表示的十六进制数等值的的十进制数。hexdec() 将一个十六进制字符串转换为十进制数。所能转换的最大数值为 7fffffff,即十进制的 2147483647。PHP 4.1.0 开始,该函数可以处理大数字,这种情况下,它会返回 float 类型。
hexdec() 将遇到的所有非十六进制字符替换成 0。这样,所有左边的零都被忽略,但右边的零会计入值中。五,任意进制转换 base_convert() 函数$hexadecimal = ///'A37334///';
echo base_convert($hexadecimal, 16, 2);//输出 101000110111001100110100
base_convert
(PHP 3 = 3.0.6, PHP 4, PHP 5)base_convert -- 在任意进制之间转换数字
说明
string base_convert ( string number, int frombase, int tobase )
返回一字符串,包含 number 以 tobase 进制的表示。number 本身的进制由 frombase 指定。frombase 和 tobase 都只能在 2 和 36 之间(包括 2 和 36)。高于十进制的数字用字母 a-z 表示,例如 a 表示 10,b 表示 11 以及 z 表示 35。
PHP符串处理函数
PHP5字符串处理函数
addcslashes — 为字符串里面的部分字符添加反斜线转义字符
addslashes — 用指定的方式对字符串里面的字符进行转义
bin2hex — 将二进制数据转换成十六进制表示
chop — rtrim() 的别名函数
chr — 返回一个字符的ASCII码
chunk_split — 按一定的字符长度将字符串分割成小块
convert_cyr_string — 将斯拉夫语字符转换为别的字符
convert_uudecode — 解密一个字符串
convert_uuencode — 加密一个字符串
count_chars — 返回一个字符串里面的字符使用信息
crc32 — 计算一个字符串的crc32多项式
crypt — 单向散列加密函数
echo — 用以显示一些内容
explode — 将一个字符串用分割符转变为一数组形式
fprintf — 按照要求对数据进行返回,并直接写入文档流
get_html_translation_table — 返回可以转换的HTML实体
hebrev — 将Hebrew编码的字符串转换为可视的文本
hebrevc — 将Hebrew编码的字符串转换为可视的文本
html_entity_decode — htmlentities ()函数的反函数,将HTML实体转换为字符
htmlentities — 将字符串中一些字符转换为HTML实体
htmlspecialchars_decode — htmlspecialchars()函数的反函数,将HTML实体转换为字符
htmlspecialchars — 将字符串中一些字符转换为HTML实体
implode — 将数组用特定的分割符转变为字符串
join — 将数组转变为字符串,implode()函数的别名
levenshtein — 计算两个词的差别大小
localeconv — 获取数字相关的格式定义
ltrim — 去除字符串左侧的空白或者指定的字符
md5_file — 将一个文件进行MD5算法加密
md5 — 将一个字符串进行MD5算法加密
metaphone — 判断一个字符串的发音规则
money_format — 按照参数对数字进行格式化的输出
nl_langinfo — 查询语言和本地信息
nl2br — 将字符串中的换行符“n”替换成“
”
number_format — 按照参数对数字进行格式化的输出
ord — 将一个ASCII码转换为一个字符
parse_str — 把一定格式的字符串转变为变量和值
print — 用以输出一个单独的值
printf — 按照要求对数据进行显示
quoted_printable_decode — 将一个字符串加密为一个8位的二进制字符串
quotemeta — 对若干个特定字符进行转义
rtrim — 去除字符串右侧的空白或者指定的字符
setlocale — 设置关于数字,日期等等的本地格式
sha1_file — 将一个文件进行SHA1算法加密
sha1 — 将一个字符串进行SHA1算法加密
similar_text — 比较两个字符串,返回系统认为的相似字符个数
soundex — 判断一个字符串的发音规则
sprintf — 按照要求对数据进行返回,但是不输出
sscanf — 可以对字符串进行格式化
str_ireplace — 像str_replace()函数一样匹配和替换字符串,但是不区分大小写
str_pad — 对字符串进行两侧的补白
str_repeat — 对字符串进行重复组合
str_replace — 匹配和替换字符串
str_rot13 — 将字符串进行ROT13加密处理
str_shuffle — 对一个字符串里面的字符进行随机排序
str_split — 将一个字符串按照字符间距分割为一个数组
str_word_count — 获取字符串里面的英文单词信息
strcasecmp — 对字符串进行大小比较,不区分大小写
strchr — 通过比较返回一个字符串的部分strstr()函数的别名
strcmp — 对字符串进行大小比较
strcoll – 根据本地设置对字符串进行大小比较
strcspn — 返回字符连续非匹配长度的值
strip_tags — 去除一个字符串里面的HTML和PHP代码
stripcslashes — 反转义addcslashes()函数转义处理过的字符串
stripos — 查找并返回首个匹配项的位置,匹配不区分大小写
stripslashes — 反转义addslashes()函数转义处理过的字符串
stristr — 通过比较返回一个字符串的部分,比较时不区分大小写
strlen — 获取一个字符串的编码长度
strnatcasecmp — 使用自然排序法对字符串进行大小比较,不区分大小写
strnatcmp — 使用自然排序法对字符串进行大小比较
strncasecmp — 对字符串的前N个字符进行大小比较,不区分大小写
strncmp — 对字符串的前N个字符进行大小比较
strpbrk — 通过比较返回一个字符串的部分
strpos — 查找并返回首个匹配项的位置
strrchr — 通过从后往前比较返回一个字符串的.部分
strrev — 将字符串里面的所有字母反向排列
strripos — 从后往前查找并返回首个匹配项的位置,匹配不区分大小写
strrpos – 从后往前查找并返回首个匹配项的位置
strspn — 匹配并返回字符连续出现长度的值
strstr — 通过比较返回一个字符串的部分
strtok — 用指定的若干个字符来分割字符串
strtolower — 将字符串转变为小写
strtoupper –将字符串转变为大写
strtr — 对字符串比较替换
substr_compare — 对字符串进行截取后的比较
substr_count — 计算字符串中某字符段的出现次数
substr_replace — 对字符串中的部分字符进行替换
substr — 对字符串进行截取
trim — 去除字符串两边的空白或者指定的字符
ucfirst — 将所给字符串的第一个字母转换为大写
ucwords — 将所给字符串的每一个英文单词的第一个字母变成大写
vfprintf — 按照要求对数据进行返回,并直接写入文档流
vprintf — 按照要求对数据进行显示
vsprintf — 按照要求对数据进行返回,但是不输出
wordwrap — 按照一定的字符长度分割字符串
strtolower()函数把所有字符变成小写,strtoupper()函数把所有字符变成大写,ucfirst()函数将所给字符串的第一个字母转换为大写,ucwords()函数将所给字符串的每一个英文单词的第一个字母变成大写。ucfirst()只处理字符串的首个字符,ucwords()只处理每个单词的首字母(以空格来界定是否是单词,“today!Hi”、“today.Hi” 会被认为是一个单词),对于其余字母的大小写状态并不改变。 ;