幾道PHP筆試題
1. 如何用php的環(huán)境變量得到一個(gè)網(wǎng)頁(yè)地址的內(nèi)容?ip地址又要怎樣得到?
2. 求兩個(gè)日期的差數(shù),例如2007-2-5 ~ 2007-3-6 的'日期差數(shù)
3. 請(qǐng)寫一個(gè)函數(shù),實(shí)現(xiàn)以下功能:
字符串“open_door” 轉(zhuǎn)換成 “OpenDoor”、”make_by_id” 轉(zhuǎn)換成 ”MakeById”,
幾道PHP筆試題
。4. 要求寫一段程序,實(shí)現(xiàn)以下數(shù)組$arr1轉(zhuǎn)換成數(shù)組$arr2:
$arr1 = array (
’0′ => array (‘fid’ => 1, ‘tid’ => 1, ‘name’ =>’Name1′ ),
’1′ => array (‘fid’ => 1, ‘tid’ => 2 , ‘name’ =>’Name2′ ),
’2′ => array (‘fid’ => 1, ‘tid’ => 5 , ‘name’ =>’Name3′ ),
’3′ => array (‘fid’ => 1, ‘tid’ => 7 , ‘name’ =>’Name4′ ),
’4′ => array (‘fid’ => 3, ‘tid’ => 9, ‘name’ =>’Name5′ )
);
$arr2 = array (
’0′ => array (
’0′ => array ( ‘tid’ => 1, ‘name’ => ‘Name1′),
’1′ => array ( ‘tid’ => 2, ‘name’ => ‘Name2′),
’2′ => array ( ‘tid’ => 5, ‘name’ => ‘Name3′),
’3′ => array ( ‘tid’ => 7, ‘name’ => ‘Name4′)
),
’1′ => array (
’0′ => array ( ‘tid’ => 9, ‘name’ => ‘Name5′ )
)
);
5. 請(qǐng)簡(jiǎn)述數(shù)據(jù)庫(kù)設(shè)計(jì)的范式及應(yīng)用,
資料共享平臺(tái)
《幾道PHP筆試題》(http://www.msguai.com)。一般第3范式就足以,用于表結(jié)構(gòu)的優(yōu)化,這樣做既可以避免應(yīng)用程序過于復(fù)雜同時(shí)也避免了SQL語句過于龐大所造成系統(tǒng)效率低下。
6.一個(gè)表中的Id有多個(gè)記錄,把所有這個(gè)id的記錄查出來,并顯示共有多少條記錄數(shù),用SQL語句及視圖、存儲(chǔ)過程分別實(shí)現(xiàn)。
DELIMITER //
CREATE PROCEDURE ProcGet
(
IN ID_a INT(11)
)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN END;
SELECT COUNT(*) AS Sum FROM News Where ID = ID_a;
END;//
CALL ProcGet(88)//
7 表中有A B C三列,用SQL語句實(shí)現(xiàn):當(dāng)A列大于B列時(shí)選擇A列否則選擇B列,當(dāng)B列大于C列時(shí)選擇B列否則選擇C列。
DELIMITER //
CREATE PROCEDURE ProcOut()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN END;
DECLARE Sum_a INT(11);
DECLARE Sum_b INT(11);
DECLARE Sum_c INT(11);
– 獲取A列中的總值 <–
DECLARE cur_1 CURSOR FOR SELECT SUM(A) FROM table_name;
OPEN cur_1;
FETCH cur_ 1 INTO Sum_a;
CLOSE cur_1;
– 獲取B列中的總值 <–
DECLARE cur_2 CURSOR FOR SELECT SUM(B) FROM table_name;
OPEN cur_2;
FETCH cur_ 2 INTO Sum_b;
CLOSE cur_2;
– 獲取C列中的總值 <–
DECLARE cur_3 CURSOR FOR SELECT SUM(C) FROM table_name;
OPEN cur_3;
FETCH cur_ 3 INTO Sum_c;
CLOSE cur_3;
IF Sum_a > Sum_b THEN
SELECT A FROM table_name;
ELSEIF Sum_b > Sum_c THEN
SELECT B FROM table_name;
【幾道PHP筆試題】相關(guān)文章:
2.PHP筆試題