1、 PHP试题带答案 精品文档 一、是非题:(每题1分,共10分) (说明:认为陈述正确的在括号内打“√”;否则在括号内打“×”) 评卷人 得分 1.PHP中变量名“$_abc”不是合法的。( ) 2.PHP只能使用Mysql数据库。( ) 3.PHP中的数组键必须为数字,且从“0”开始。( ) 4.全等运算符“===”在比较时,只有在两者的数据类型和值都相同时才返回True。( ) 5.“mysql_connect( )”与“@mysql_connect( )”没有任何区别。(
2、 ) 6.使用continue语句可以实现PHP程序的跳转。( ) 7.HTML中的Form表单数据必须使用Submit按钮才可以提交。( ) 8.PHP中的die()和exit()都可以实现程序中止退出功能。( ) 9.PHP程序中可以随时嵌入HTML代码和JS代码。( ) 10.PHP中的Session功能可以完全不受制于客户端的Cookie设置。( ) 二、填空题:(每空1分,共10分) 评卷人 得分 1.HTML的Form表单中定义单选按钮需要使用INPUT的 类型
3、定义复选按钮需要使用INPUT的 类型。 2.PHP表达式10%2.5值为 ,表达式10/2.5值为 。 3.Mysql数据库服务默认开放的端口号是 ,默认管理员为 。 4.为了能够避免SQL注入,你需要坚持 。 5.表达式“'Testing'.'3'+'5'.'12'”的值为 。 6.PHP函数中可以利用 向外返回一个值,可以使用
4、 声明一个全局变量。 三、单选题:(每题2分,共30分) (说明:将认为正确答案的字母填写在每小题后而的括号内) 评卷人 得分 1.输出结果为:( ) A.123 B.423 C.122 D.413 2.The PHP function that is used to create functions, headers, footers, or elements that w
5、ill be reused on multiple pages is( ). A.require() B.refill() C.reuse() D.None of the Above 3.If you want to come out of a while loop which of the following is used? ( ) A.exit B.close C.end D.break 4.Which of the following statement about P
6、HP is FALSE?( ) A.PHP is a web scripting language. B.PHP is a client side language. C.PHP is server-side scripting language that allows you to generate dynamic websites. D.All the Above 5.Which of the following are valid float values? A.4.5678 B.4.0 C.7e4 D.All o
7、f above 6.Study following steps and determine the correct order (1) Open a connection to MySQL server (2) Execute the SQL query (3) Fetch the data from query (4) Select database (5) Close Connection A.1, 4, 2, 3, 5 B.4, 1, 2, 3, 5 C.1, 5, 4, 2, 1 D.4, 1, 3, 2, 5 7.What is th
8、e correct way to add 1 to the $count variable? ( ) A.$count =+1 B.++count C.count++; D.$count++; 8.What is the correct way to create a function in PHP?( ) A.function myFunction() B.new_function myFunction() C.create myFunction() D.void myFunction() 9.下列哪个HTML标记是用来标记图像
9、的?( )
A. B.
10、 C.& D.* 13.输出结果为:( ) A.1,2,3 B.1,2, C.1,2 D.12, 14.'red',2,'name'=>'apple',4); echo $a[2]; ?>输出结果为:( ) A.red B.4 C.apple D.2 15.下列哪个不是PHP的输出命令:( )
11、 A.echo B.printf() C.print D.write 四、程序分析:(每题2分,共30分) (说明:写出各PHP程序运行后在浏览器里看到的结果) 评卷人 得分 1. 你的成绩及格了! 你的成绩不及格! 2.
12、 3. 4.
13、 5.=1) test(); } test(); ?> 6.
14、); ?> 7.23); ?> 8.5) break; echo ++$i; } ?>
15、 9. 10.
16、 11. 12.
17、 13."南阳理工",0=>"cba",123); $num=count($sz); echo $num; ?> 14.
18、ree"; default:echo "other integer"; } ?> 15. 五、编程题:(共20分) 评卷人 得分 1.利用PHP的循环语句,
19、输出1—100中所有的偶数。(5分) 2.假设MySQL数据库主机为“localhost”,用户名和密码都为“root”,数据库“student”中有一数据表“score”,有三个字段,类型及说明如下: 字段 类型 说明 id int 自动增1 表的主键 name varchar(20) 学生姓名 score int 成绩 请根据功能要求编写三个PHP网页:add.php、view.php、op.php。 (1)add.php。功能要求:实现添加记录的功能,其中包括输入姓名及成绩的表单界面、提交表单后的处理程序等。(5分) (2)view.php。功能要求:把表中所有学生的姓名和成绩信息输出到网页上。(5分) (3)op.php。功能要求:把所有分数在55(包括55)到59(包括59)的学生的成绩改为60;把姓名为“测试”的记录删除。(5分) 收集于网络,如有侵权请联系管理员删除






