面試總結
今天去了北京著名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.