• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

php基本数据类型

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

trim()函数,用于去除字符串首尾空格和特殊字符
返回的是去掉的空格和特殊字符后的字符串

string trim(string str [,string charlist]);  str 要操作的字符串对象, 第二个参数为可选参数,选取要从字符串中删除的字符,不设置该参数,表示要将所有的字符删除

ltrim()函数,用于去除字符串左边的空格和特殊字符:

string ltrim(string str [,string charlist]);

rtrim()函数,用于去除右边的空格和特殊的字符:

string rtrim(string str[,string charlist]);

转义字符,手动转义:使用""字符。字符串的定义有单引号,双引号,界定符(<<<)。

自动转义:addslashes()函数和stripslashes()函数
addslashes()函数,用于为字符串加入“”。

string addslashes(string str)

stripslashes()函数,用于将addslashes()函数转义后的字符串返回原样。

string stripslashes(string str)

对要转义字符串,还原字符串进行一定范围的限制,addcslashes()函数和stripcslashes()函数。

addcslashes()函数:转换成八进制表示

string addcslashes(string str, string charlist)

stripcslashes()函数,用于对addcslashes()函数转义过的字符串还原。

string stripcslashes(string str)

获取字符串的长度,strlen()函数:汉字占两个字符

int strlen(string str)

截取字符串,substr()函数:

string substr(string str, int start [,int length])  str指定的字符串对象 start截取开始的字符串位置 length截取字符的个数

比较字符串,按照字节比较:strcmp()函数和strcasecmp()函数,按照自然排序strnatcmp()函数,按照从源字符串的位置开始比较strncmp()函数。

strcmp()函数区分字符的大小写
strcasecmp()函数不区分字符的大小写

int strcmp ( string str1, string str2) 相等则返回0 

字符串之间的比较,strcmp()函数比较。

strnatcmp()函数来实现自然排序字符串比较:strnatcmp()用于比较字符串中数字部分

int strnatcmp(string str1, string str2);

strncmp()函数由于比较字符串中前n个字符:

int strncmp(string str1, string str2, int len)

检索字符串:查找指定的关键字

string strstr(string haystack, string needle) 区分大小写

substr_count()函数检索子串出现的次数

int substr_count(string haystack,string needle)

str_ireplace() / str_replace()函数和substr_replace()函数

mixed str_ireplace ( mixed search, mixed replace, mixed subject [, int &count])

search需要查找的字符串
replace替换的值
subject查找的范围
count替换的数量

substr_replace()函数:对指定字符串中的部分字符串进行替换

string substr_replace(string str,string repl,int start,[int length])

str要操作的原始字符串,repl 替换后的新字符串,start指定替换字符串开始的位置,负数表示起始位置从字符串的结尾开始,length指定返回的字符串长度,负数表示起始位置从字符串的结尾开始,0表示插入而非替代 。

格式化字符串,number_format()函数用来将数字字符串格式化

string number_format(float number,[int num_decimal_places],[string dec_seperator],string thousands_ seperator)

分割字符串,explode()函数,对一个字符串进行分割,返回值为数组:

array explode(string separator,string str,[int limit])

合成字符串,将数组的内容组合成一个新字符串

string implode(string glue, array pieces)

正则表达式:PHP中的POSIX函数,PHP中的PCRE函数。

一个正则表达式包含 元字符 和 文本字符。

行定位符(^和$)
“^”表示行的开始
“$”表示行的结尾

单词定界符(\b、\B)

字符类([ ])

选择字符(|)

连字符(-)[a-zA-Z]

排除字符([^])[^a-zA-Z]

限定符(? * + {n,m})

点号字符(.)^d.s$
转义字符(\)
括号字符(())

POSIX扩展正则表达式函数

ereg()函数和eregi()函数

bool ereg/eregi ( string pattern, string string [, array regs] )

ereg_replace()函数和eregi_replace()函数

string ereg_replace/eregi_replace ( string pattern, string replacement, string string )

split()函数和spliti()函数

array split/spliti ( string pattern, string string [, int limit] )

PCRE兼容正则表达式函数

1、preg_grep()函数

array preg_grep ( string pattern, array input )

2、preg_match()函数和preg_match_all()函数

int preg_match/preg_match_all ( string pattern, string subject [, array matches] )

3、preg_quote()函数 函数返回转义后的字串

string preg_quote ( string str [, string delimiter] )

4、preg_replace()函数

mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit] )

5、preg_replace_callback()函数

mixed preg_replace_callback ( mixed pattern, callback callback, mixed subject [, int limit] )

6、preg_split()函数

array preg_split ( string pattern, string subject [, int limit ] )
<table width="765" height="229" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="229" colspan="2"><img src="images/bg_03.jpg" width="765" height="229" border="0" href="index.php" /></td>
  </tr>
  <tr>
    <td width="565" height="364" align="center" valign="top">   <form name="reg_check" method="post" action="index_ok.php" onSubmit="return chkreg(reg_check,'all')">
      <table width="550" height="270" border="0" align="center" cellpadding="0" cellspacing="0">
            
                <tr>
                  <td height="38" colspan="3" valign="bottom"><img src="images/bg_05.jpg" width="543" height="30" /></td>
                </tr>
                <tr>
                  <td width="110" height="30"><div align="right">会员名:</div></td>
                  <td colspan="2" align="left">&nbsp;<input type="text" name="recuser" size="20"  onBlur="chkreg(reg_check,0)">
                    <font color="#FF0000">*</font>&nbsp;
                  <div id="check_recuser" style="color:#F1B000"></div></td>
                </tr>
                
                <tr>
                  <td height="30"><div align="right">详细联系地址:</div></td>
                  <td height="30" colspan="2" align="left">&nbsp;<input type="text" name="address" size="50"  onBlur="chkreg(reg_check,1)">
                    <font color="#FF0000">*</font>&nbsp;
                  <div id="check_address" style="color:#F1B000"></div></td>
                </tr>
                <tr>
                  <td height="30"><div align="right">邮政编码:</div></td>
                  <td height="30" colspan="2" align="left">&nbsp;<input type="text" name="postalcode" size="20"  onBlur="chkreg(reg_check,2)"><div id="check_postalcode" style="color:#F1B000"></div></td>
                </tr>
                <tr>
                  

trim()函数,用于去除字符串首尾空格和特殊字符
返回的是去掉的空格和特殊字符后的字符串

string trim(string str [,string charlist]);  str 要操作的字符串对象, 第二个参数为可选参数,选取要从字符串中删除的字符,不设置该参数,表示要将所有的字符删除

ltrim()函数,用于去除字符串左边的空格和特殊字符:

string ltrim(string str [,string charlist]);

rtrim()函数,用于去除右边的空格和特殊的字符:

string rtrim(string str[,string charlist]);

转义字符,手动转义:使用""字符。字符串的定义有单引号,双引号,界定符(<<<)。

自动转义:addslashes()函数和stripslashes()函数
addslashes()函数,用于为字符串加入“”。

string addslashes(string str)

stripslashes()函数,用于将addslashes()函数转义后的字符串返回原样。

string stripslashes(string str)

对要转义字符串,还原字符串进行一定范围的限制,addcslashes()函数和stripcslashes()函数。

addcslashes()函数:转换成八进制表示

string addcslashes(string str, string charlist)

stripcslashes()函数,用于对addcslashes()函数转义过的字符串还原。

string stripcslashes(string str)

获取字符串的长度,strlen()函数:汉字占两个字符

int strlen(string str)

截取字符串,substr()函数:

string substr(string str, int start [,int length])  str指定的字符串对象 start截取开始的字符串位置 length截取字符的个数

比较字符串,按照字节比较:strcmp()函数和strcasecmp()函数,按照自然排序strnatcmp()函数,按照从源字符串的位置开始比较strncmp()函数。

strcmp()函数区分字符的大小写
strcasecmp()函数不区分字符的大小写

int strcmp ( string str1, string str2) 相等则返回0 

字符串之间的比较,strcmp()函数比较。

strnatcmp()函数来实现自然排序字符串比较:strnatcmp()用于比较字符串中数字部分

int strnatcmp(string str1, string str2);

strncmp()函数由于比较字符串中前n个字符:

int strncmp(string str1, string str2, int len)

检索字符串:查找指定的关键字

string strstr(string haystack, string needle) 区分大小写

substr_count()函数检索子串出现的次数

int substr_count(string haystack,string needle)

str_ireplace() / str_replace()函数和substr_replace()函数

mixed str_ireplace ( mixed search, mixed replace, mixed subject [, int &count])

search需要查找的字符串
replace替换的值
subject查找的范围
count替换的数量

substr_replace()函数:对指定字符串中的部分字符串进行替换

string substr_replace(string str,string repl,int start,[int length])

str要操作的原始字符串,repl 替换后的新字符串,start指定替换字符串开始的位置,负数表示起始位置从字符串的结尾开始,length指定返回的字符串长度,负数表示起始位置从字符串的结尾开始,0表示插入而非替代 。

格式化字符串,number_format()函数用来将数字字符串格式化

string number_format(float number,[int num_decimal_places],[string dec_seperator],string thousands_ seperator)

分割字符串,explode()函数,对一个字符串进行分割,返回值为数组:

array explode(string separator,string str,[int limit])

合成字符串,将数组的内容组合成一个新字符串

string implode(string glue, array pieces)

正则表达式:PHP中的POSIX函数,PHP中的PCRE函数。

一个正则表达式包含 元字符 和 文本字符。

行定位符(^和$)
“^”表示行的开始
“$”表示行的结尾

单词定界符(\b、\B)

字符类([ ])

选择字符(|)

连字符(-)[a-zA-Z]

排除字符([^])[^a-zA-Z]

限定符(? * + {n,m})

点号字符(.)^d.s$
转义字符(\)
括号字符(())

POSIX扩展正则表达式函数

ereg()函数和eregi()函数

bool ereg/eregi ( string pattern, string string [, array regs] )

ereg_replace()函数和eregi_replace()函数

string ereg_replace/eregi_replace ( string pattern, string replacement, string string )

split()函数和spliti()函数

array split/spliti ( string pattern, string string [, int limit] )

PCRE兼容正则表达式函数

1、preg_grep()函数

array preg_grep ( string pattern, array input )

2、preg_match()函数和preg_match_all()函数

int preg_match/preg_match_all ( string pattern, string subject [, array matches] )

3、preg_quote()函数 函数返回转义后的字串

string preg_quote ( string str [, string delimiter] )

4、preg_replace()函数

mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit] )

5、preg_replace_callback()函数

mixed preg_replace_callback ( mixed pattern, callback callback, mixed subject [, int limit] )

6、preg_split()函数

array preg_split ( string pattern, string subject [, int limit ] )
<table width="765" height="229" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="229" colspan="2"><img src="images/bg_03.jpg" width="765" height="229" border="0" href="index.php" /></td>
  </tr>
  <tr>
    <td width="565" height="364" align="center" valign="top">   <form name="reg_check" method="post" action="index_ok.php" onSubmit="return chkreg(reg_check,'all')">
      <table width="550" height="270" border="0" align="center" cellpadding="0" cellspacing="0">
            
                <tr>
                  <td height="38" colspan="3" valign="bottom"><img src="images/bg_05.jpg" width="543" height="30" /></td>
                </tr>
                <tr>
                  <td width="110" height="30"><div align="right">会员名:</div></td>
                  <td colspan="2" align="left">&nbsp;<input type="text" name="recuser" size="20"  onBlur="chkreg(reg_check,0)">
                    <font color="#FF0000">*</font>&nbsp;
                  <div id="check_recuser" style="color:#F1B000"></div></td>
                </tr>
                
                <tr>
                  <td height="30"><div align="right">详细联系地址:</div></td>
                  <td height="30" colspan="2" align="left">&nbsp;<input type="text" name="address" size="50"  onBlur="chkreg(reg_check,1)">
                    <font color="#FF0000">*</font>&nbsp;
                  <div id="check_address" style="color:#F1B000"></div></td>
                </tr>
                <tr>
                  <td height="30"><div align="right">邮政编码:</div></td>
                  <td height="30" colspan="2" align="left">&nbsp;<input type="text" name="postalcode" size="20"  onBlur="chkreg(reg_check,2)"><div id="check_postalcode" style="color:#F1B000"></div></td>
                </tr>
                <tr>
                  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP+MySQL中对UTF-8,UTF8(utf8),setnamesgbk的理解发布时间:2022-07-10
下一篇:
PHP下载远程图片发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap