Home  >  Article  >  php教程  >  php5与mysql5 web 开发技术详解-2 字符串操作

php5与mysql5 web 开发技术详解-2 字符串操作

WBOY
WBOYOriginal
2016-06-13 10:55:171045browse

字符串学习主要是掌握内置函数。

函数太多,至今没有记住多少,先简单的把函数记录下来,以后再做补充。

 

 

1、定义方式: 单引号、双引号、或者{}

       {}显示索引数组方便,双引号解析变量

2、手动转意字符串数据

      \ 符号来实现

      可用addslashes()、addcslashes()函数自定义转移

 

3、序列化和反序列化 serialize()、unserialize()

    

4、字符串整理

      trim()、ltrim()、rtrim()

      去掉字符串中的空格、换行符(\n,\r)、水平和垂直制表符(\t,\v)以及字符串结束符(\0).

5、格式化字符串

     nl2br()

     wordwrap()

     strtolower()

     strtoupper()

     ucfirst()

     ucwords()

6、分割

     explode() 和 同名 join()

     例: explode("@",$email) ;

 

7、字符串截取

     substr(‘目标串',起点,终点)

8、strlen()  /  mb_strlen()

 

9、str_word_count()

       结合array_count_values() 统计单词出现次数

10、查找www.2cto.com

       strstr($string,"关键字") ,stristr() ,strrch()

       strpos()

       str_repeat()

       substr_count()

11、处理

       str_replace()

       substr_replace()

       strrev()

       htmlspecialchars() ,htmlentitles()  将,&, "  等特殊字符转换为html实体

       strip_tags()  清楚html标签

       strncmp(),strcmp()

       strok() 解析字符串

        strpbrk()

        strspn(),strcspn()

        str_replace()

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn