Home> php教程> php手册> body text

PHP面试题及答案,php试题及答案

WBOY
Release: 2016-06-13 08:55:38
Original
1704 people have browsed it

PHP面试题及答案,php试题及答案

1.请写一个函数,实现以下功能:
字符串"open_door"转换成 "OpenDoor"、"make_by_id" 转换成"MakeById"。
function str_change($str) {
$str = str_replace ( "_", " ", $str );
$str = ucwords ( $str );
$str = str_replace ( " ", "", $str );
return $str; }

2. 要求写一段程序,实现以下数组$arr1转换成数组$arr2:
$arr1 = array (
'0' => array ('fid' => 1, 'tid' => 1, 'name' =>'Name1' ),
'1' => array ('fid' => 1, 'ti' => 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′ ) ) );

$arr1 = array (
'0' => array ('fid' => 1, 'tid' => , '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')
);
function changeArrayStyle($arr){
foreach($arr as $key=>$value){
$result[$value[\fid\]][]=$value;
}
return array_values($result);
}
$arr2=changeArrayStyle($arr1);
echo "

";
var_dump($arr2);
?>

3. 请简述数据库设计的范式及应用。
一般第3范式就足以,用于表结构的优化,这样做既可以避免应用程序过于复杂同时也避免了SQL语句过于庞大所造成系统效率低下。
ANSWER:
第一范式:若关系模式R的每一个属性是不可再分解的,再属于第一范式。
第二范式:若R属于第一范式,且所有的非码属性都完全函数依赖于码属性,则为第二范式。
第三范式:若R属于第二范式,且所有的非码属性没有一个是传递函数依赖于候选码,则属于第三范式。

Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!