php期末考试试题

上传人:小** 文档编号:93140987 上传时间:2019-07-17 格式:DOC 页数:5 大小:54.50KB
返回 下载 相关 举报
php期末考试试题_第1页
第1页 / 共5页
php期末考试试题_第2页
第2页 / 共5页
php期末考试试题_第3页
第3页 / 共5页
php期末考试试题_第4页
第4页 / 共5页
php期末考试试题_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《php期末考试试题》由会员分享,可在线阅读,更多相关《php期末考试试题(5页珍藏版)》请在金锄头文库上搜索。

1、PHP程序设计上机期末考试试题一、 调试下列 各小题的输入结果(每题10分,共34分)1、调试答案:_.2、$c?4:5;echo $a;?调试答案:_.3、1,12=2); $arr=3; $arrx=4; print_r($arr); echo ; unset($arr5); print_r($arr); echo “”; unset($arr); print_r($arr); ?调试答案:_.4、10) break; echo $i+. ; echo ;?调试答案:_.5、?php $m=2;$n=3; $table=; for($i=1;$i=$m;$i+) $table.=; for

2、($j=1;$j=$n;$j+) $table .= m:$i, n:$j; $table .= ; $table .= ; echo $table;?调试答案:_.6、?php $id=gzopen(test.gz,w); gzwrite($id,123456789n,5); gzclose($id); $id=gzopen(test.gz,r); echo gzgetc($id).; echo gzgets($id,4).; gzclose($id);$id=gzopen(test.gz,w); gzputs($id,this is a test.n); gzputs($id,the se

3、cond line.n); gzclose($id);$id=gzopen(test.gz,r); echo gzgetss($id,10).; gzpassthru($id); echo ; gzclose($id);?调试答案:_.二、 编程题及程序调试(每题20分 共计40分)1、有一个数组$a=array(4,3,8,9,2),将其重新排序并输入结果,按从小到大的顺序排列。1、?php$a = array(4,3,8,9,2); $j = 1; $temp = 0; while($j count($a) for ($i=0; $i $a$i+1) $temp = $a$i; $a$i

4、= $a$i+1; $a$i+1 = $temp; $j+; print_r($a);?2、数据库qzh中有一个表user,其结构为(name,tel,content,date),已有如下三条记录张三 13333663366 大专毕业 2006-10-11张三 13612312331 本科毕业 2006-10-15张四 021-55665566 中专毕业 2006-10-15请使用php编写程序实现:(1)查询所有姓名为“张三”的记录,并使用mysql_fetch_array函数输出查询结果;(2)添加记录(小王 13254748547 高中毕业 2007-05-06)至表中;(3)张三的时间

5、更新成为当前系统时间。注意:请将以上三个操作作为一个事务来处理,即以上三个操作全部成功时,才提交事务,只要有一个操作失败,其余两个操作不能提交。$dbconn = mysqli_connect(localhost, root, 123, test) or die(不能连接到数据库);mysqli_autocommit($dbconn, false);/查询user表中所有姓名为“张三”的记录$sql1 = select * from user where name=张三;$result = mysqli_query($dbconn, $sql1);if($result != true) mys

6、qli_rollback($dbconn); /如果出错,则回滚到开始状态/添加记录(小王 13254748547 高中毕业 2007-05-06)至表中$sql2 = insert into user(name,tel,content,nf) values(小王,13254748547,高中毕业,20070506);$result = mysql_query($dbconn,$sql2);if($result != true) mysqli_rollback($dbconn); /如果出错,则回滚到开始状态/更改张三的毕业时间为当前系统时间$sql3 = update user set nf

7、=now() where name=张三;$result = mysqli_query($dbconn, $sql3);if($result != true) mysqli_rollback($dbconn); /如果出错,则回滚到开始状态/没有任何错误,则提交,完成一次事务操作mysqli_commit($dbconn);/关闭数据库连接mysqli_close($dbconn);?php$conn = mysql_connect(localhost,root,123);mysql_select_db(test);$query = SELECT * FROM user;$result = m

8、ysql_query($query,$conn);/使用mysql_fetch_array函数输出查询结果while($row = mysql_fetch_array($result) echo $row0. ; echo $row1. ; echo $row2. ; echo $row3.;?答案一:D B B D C C B D B D二:1、无输出 2、4 3、Array ( 5 = 1 12 = 2 13 = 3 x = 4 ) Array ( 12 = 2 13 = 3 x = 4 )4、1 2 3 4 5 6 7 8 9 105、m:1, n:1m:1, n:2m:1, n:3m:

9、2, n:1m:2, n:2m:2, n:36、1234tlethis is a test.the second line.三、1、?php$a = array(4,3,8,9,2); $j = 1; $temp = 0; while($j count($a) for ($i=0; $i $a$i+1) $temp = $a$i; $a$i = $a$i+1; $a$i+1 = $temp; $j+; print_r($a);?2、?php$conn = mysql_connect(localhost,root,123);mysql_select_db(test);$query = SELECT * FROM user;$result = mysql_query($query,$conn);/使用mysql_fetch_array函数输出查询结果while($row = mysql_fetch_array($result) echo $row0. ; echo $row1. ; echo $row2. ;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号