您好,欢迎访问一九零五行业门户网

php程序员面试分享_PHP教程

面试总结
今天去了北京著名it公司进行php程序员的面试。这是人生第一次么,怎么不紧张?我是不是有病。不是,这叫自信呵.
首先是做一些笔试题。
1.mysql数据库索引使用的数据结构?这样做的好处是?
可以参考这篇博文:http://blog.csdn.net/ant_ren/article/details/2932068
2.有两个字符串a和b,判断b字符串是否出现在a中。不考虑大小写。。
我的答案是:使用stripos()这个函数来解决的。
if(stripos($a,$b)>-1) echo b in a;else echo b not in a;
拓展:
但是如果是不考虑顺序的话,问b字符串中的字符是否全部出现在a中。。。
那我们就需要用循环来解决的。下面提供解决方案:
$b_arr = str_split($b);for(var $i=0,$len = count($b_arr); $i starttime = microtime(); } function stop(){//程序运行结束 $this->stoptime = microtime(); } function spent(){//程序运行花费的时间 if ($this->timespent) { return $this->timespent; } else { list($startmicro, $startsecond) = explode( , $this->starttime); list($stopmicro, $stopsecond) = explode( , $this->stoptime); $start = doubleval($startmicro) + $startsecond; $stop = doubleval($stopmicro) + $stopsecond; $this->timespent = $stop - $start; return substr($this->timespent,0,8).秒;//返回获取到的程序运行时间差 } } } $timer = new timer(); $timer->start(); //...程序运行的代码 $timer->stop(); echo 程序运行时间为:.$timer->spent();
下面是简单版的。
class timer{ private $t = 0; public function start(){ $this->t = microtime(true); } public function stop(){ return microtime(true)- $this->t; }}$time = new timer();$time->start();//do somethings...$t = $time->stop();
7.建立复合索引应该注意的事项。
(1)对一张表来说,如果有一个复合索引 on (col1,col2)就没有必要同时建立一个单索引 on col1。
(2)如果查询条件需要,可以在已有单索引 on col1的情况下,添加复合索引on (col1,col2),对于效率有一定的提高。
(3)同时建立多字段(包含5、6个字段)的复合索引没有特别多的好处,相对而言,建立多个窄字段(仅包含一个,或顶多2个字段)的索引可以达到更好的效率和灵活性。
8.设计一张数据库表。该数据表用来存储经常插入和查询的url数据。
并解释为什么这么设计的原因。
create table url( `id` int(11) not null primary key auto_increment comment 主键, `url` varchar(255) not null comment url 内容, `name` varchar(50) comment url对应的名称)engine=myisam
我是这么建立的。
经常插入和删除,我觉的数据库存储引擎应该使用myisam。
如果再在url,name字段上建立一个索引就更好了。
不是我想简单写啊。这么多题目就一张a4纸啊。
这不是逼着我写简单点吗?不过我还是犯了一些低级的错误。我正在努力改正。
一点福利,分享给大家。
best wishes.
http://www.bkjia.com/phpjc/802113.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/802113.htmltecharticle面试总结 今天去了北京著名it公司进行php程序员的面试。这是人生第一次么,怎么不紧张?我是不是有病。不是,这叫自信呵. 首先是做一些...
其它类似信息

推荐信息