PHP學習網接下來天天會分享一些面試題給你們,多作題,多熟悉基礎,面試時更有信心,同時你們還能夠關注php學習網公衆號查看更多的面試題。
$str="cd"; $$str="abcde"; $$str.="ok"; echo $cd;
答案:該段代碼輸出是:okphp
$count=5; function get_count(){ static $count=0; return $count++; } echo $count; ++$count; echo get_count(); echo get_count();
答案:結果爲 5 0 1面試
MVC模式、單態模式、敏捷開發模式、瀑布流模式、螺旋模式、值對象模式、註冊模式、僞對象模式、策略模式、迭代器模式、規範模式函數
答案1:學習
function getExt($url){ $arr = parse_url($url); $file = basename($arr['path']); $ext = explode(".",$file); return $ext[1]; }
答案2:url
function getExt($url) { $url = basename($url); $pos1 = strpos($url,"."); $pos2 = strpos($url,"?"); if(strstr($url,"?")){ return substr($url,$pos1 + 1,$pos2 - $pos1 - 1); } else { return substr($url,$pos1); } }
方法一:先用strtotime轉換成unix時間戳,而後相減,除以一天的秒數86400.
方法二:先用mktime轉換成unix時間戳,而後相減,除以一天的秒數86400.spa
具體代碼以下:unix
方法一:code
class Dtime { function get_days($date1, $date2) { $time1 = strtotime($date1); $time2 = strtotime($date2); return ($time2-$time1)/86400; } } $Dtime = new Dtime; echo $Dtime->get_days('2019-2-5', '2020-3-6');
方法二:對象
$temp = explode('-', '2007-2-5'); $time1 = mktime(0, 0, 0, $temp[1], $temp[2], $temp[0]); $temp = explode('-', '2007-3-6'); $time2 = mktime(0, 0, 0, $temp[1], $temp[2], $temp[0]); echo ($time2-$time1)/86400;
sort()
根據陣列中元素的值,以英文字母順序排序,索引鍵會由 0 到 n-1 從新編號。主要是當陣列索引鍵的值無關疼癢時用來把陣列排序。 排序
assort()
PHP 沒有 assort() 函式,因此多是 asort() 的筆誤。
asort()
與 sort() 同樣把陣列的元素按英文字母順序來排列,不一樣的是全部索引鍵都得到保留,特別適合替聯想陣列排序。
ksort()
根據陣列中索引鍵的值,以英文字母順序排序,特別適合用於但願把索引鍵排序的聯想陣列。