Blogger Information
Blog 24
fans 0
comment 12
visits 15521
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字符串函数作业
移动用户-5435854
Original
754 people have browsed it

字符串函数作业

每位同学从课堂上已讲, 以及课件中提及未讲的函数中,至少选择10个函数感兴趣的进行实例演示,并发布到博客中

1、substr 返回字符串的子串 查找某个字符串

  1. echo substr('abcdef' ,2 ,2);
  2. echo '<br>';
  3. echo substr('abcdef' ,-3 ,2);

2.substr_count 统计某个字符串的出现频次

  1. echo substr_count('I am adword','a','3');

3.strlen 统计字符数量

  1. echo strlen('I am adword');

4.substr_replace 替换子字符串里面某个内容

  1. $myName='I am adword';
  2. echo substr_replace($myName,'peter',5);

5.str_split 把字符串变成数组

  1. str_split('I am adword');
  2. $name=print_r(str_split('I am adword'),true);
  3. printf('<pre>%s</pre>',$name);

6.str_pad 将字符串填充指定长度

  1. echo str_pad('php',20,'=',STR_PAD_BOTH);

7.str_repead

  1. echo str_repeat('*',100);

8.str_replace 字符串替换

  1. $url='\0422\demo1.php';
  2. echo str_replace('\\','/',$url,$nuber);
  3. echo '<br>';
  4. echo $nuber;

9.trim

  1. $web='0422demophp11111';
  2. echo '<br>';
  3. echo trim($web,'0..9');

10,md5和sha1给字符串加密

  1. $myName='I am adword';
  2. echo sha1(md5($myName));

感想:努力记忆,一个大牛的程序员和一个普通程序员的区别,可能就来自于能否完全熟记这些字符串函数,并举一反三的用在项目里面。没有捷径可走,只能多看手册,死记硬背把这些函数都背下来。然后读书破万卷下笔如有神了。作为一个刚接触php一个月不到的小白,背是奢望,先逐个能看懂,逻辑上搞明白是王道。加油。

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:这行业的大牛, 只是写得代码多而已, 也没啥了不起的, 当你写过一万行代码之后, 就算入门了, 超过10万行, 也是大牛了, 超过百万行, 就迈入了仙级队列, 出家不用更剃头了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post