php面試題6
一、總結
二、php面試題6
寫出你認為語言中的高級函數:
1)preg_replace()
2)preg_match()
3) ignore_user_abort()
4) debug_backtrace()
5) date_default_timezone_set(“PRC”)
6) get_class_methods() 得到類的方法名的數組
7) preg_split() 字符串分割成數組
8)json_encode() //js for in 關聯數組和對象
9)parse_url()
10)parse_str()
11)pathinfo()
12)array_multisort()
簡述 Cookie 的設置及獲取過程:
1)設置
$value = 'something from somewhere';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */?>
2) <?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);?>
3)獲取方法:
print_r($_COOKIE);
面向對象中接口和抽象類的區別及應用場景:
他們的不同點:
1。抽象類中可以有非抽象的方法而接口中只能夠有抽象的方法!
2。一個類可以繼承多個接口,而一個類只能繼承一個抽象類!
3。接口的使用方式通過 implements 關鍵字進行,抽象類則是通過繼承 extends 關鍵字
進行!
interface one{
function fun1();
function fun2();
}
abstract class two implements one{
abstract function fun1();
abstract function fun2();
}
class four extents two{
function fun1(){
echo "fun1";
}
function fun2(){
echo "fun2";
}
}
4、用面向對象來實現 A 對象繼承 B 和 C 對象:
class C {
function funC(){
echo "funC";
}
}
class B extends C {
function funB(){
echo "funB";
}
}
class A extends B {
function funA(){
echo "funA";
}
}
$p=new A();
$p->funC();
$p->funB();
$p->funA();
?>
寫出 Smarty 模板引擎中你最常用的關鍵詞:
1)assign
2)display
3) caching
4) left_delimiter
5) right_delimiter
6) function nocache($param, $content, &$smarty) {
return $content;
}
$smarty->register_block('nocache', 'nocache', false);
7)foreach
8)include
MySQL存儲引擎中MyISAM和InnoDB,在同樣的應用場景中各有什么優缺點,索引結構如何實現:
1)在增、刪、改和查方面,myisam要優于innodb表引擎,當數據量特別大時,他們的速度相差不大
2)innodb支持myisam所不具備的事務支持、存儲過程、行級鎖定等等
7、如下user表結構
如果是一個 Web 頻繁訪問的查詢,上題的查詢如何優化?
1)create index in_age on user(age);
2)desc select uid,name,age from user where age>20 && age<30;
3)alter table user add index in_age(age);
8、Web 開發的遇到的困難有哪些?
1)表的設計
2)sql 語句的書寫和優化
3)ajax 的使用
4)前后臺數據交互
寫出你認為語言中的高級函數:
1.數組
array_filter();
array_map();
array_multisort();
array_count_values();
array_splice();
2.字符串
htmlspecialchars();
htmlspecialchars_decode();
json_encode();
json_decode();
substr_count();
pathinfo();
parse_url();
parse_str();
3.正則
preg_match_all();
preg_replace();
5.文件
file_get_contents();
file_put_contents();
scandir();
readfile();
6.畫圖
imagecreatefromjpeg();
7.cookie與session
setcookie();
session_id();
session_name();
8.數據庫操作
mysql_fetch_assoc();
last_insert_id();
smarty模板引擎中的關鍵字:
1.assign();
2.display();
3.for
4.if
5.foreach
6.volist