今天去了北京著名IT公司进行PHP程序员的面试。这是人生第一次么,怎么不紧张?我是不是有病。不是,这叫自信呵.
首先是做一些笔试题。我的答案是:使用stripos()这个函数来解决的。
if(stripos($a,$b)>-1) echo "b in a"; else echo "b not in a";
$b_arr = str_split($b);
for(var $i=0,$len = count($b_arr); $i < $len ; ++$i){
if(stripos($a,$b_arr[$i])==-1)
return false;
return true;
}class Timer {
private $StartTime = 0;//程序运行开始时间
private $StopTime = 0;//程序运行结束时间
private $TimeSpent = 0;//程序运行花费时间
function start(){//程序运行开始
$this->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();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
不是我想简单写啊。这么多题目就一张A4纸啊。
这不是逼着我写简单点吗?不过我还是犯了一些低级的错误。我正在努力改正。
一点福利,分享给大家。
Best Wishes.
原文地址:http://blog.csdn.net/lcstrive/article/details/30453655