共220分,选择题2分×20=40分,简答题4分×15=60分,实现题8分×15=120分
一。选择(每题2分,共40分)
1.php代表什么意思?
A.Hypertext Preprocessor(超文本预处理器)
B.Hyperlink Preprocessor(超链接预处理器)
C.Personal Homepage (个人主页空间)
2.以下PHP标记哪个是错误的?
1.<? ?> 2. <?PHP ?> 3.<% %> 4.<SCRIPT language="php">...</script>
A.1 B.2 C.3 D.4 E.没有
3.下边哪个变量是非法的?
A. $_10
B. ${“MyVar”}
C. &$something
D. $10_somethings
E. $aVaR
4.print() 和 echo()的区别是什么?
A.print()可以作为一个表达式的一部分,echo() 不可以
B.echo()可以作为一个表达式的一部分,print() 不可以
C.echo() 可以用在 CLI version of PHP, print() 不可以
D.print() 可以用在 CLI version of PHP, echo() 不可以
E.没有区别
5.分析以下代码:
<?php
define("STOP_AT", 1024);
$result = array();
/* Missing code */
{
$result[] = $idx;
}
print_r($result);
?>
在/* Missing code */ 处填什么代码才能有以下的输出?
Array
{
[0] => 1
[1] => 2
[2] => 4
[3] => 8
[4] => 16
[5] => 32
[6] => 64
[7] => 128
[8] => 256
[9] => 512
}
A. foreach($result as $key => $val)
B. while($idx *= 2)
C. for($idx = 1; $idx < STOP_AT; $idx *= 2)
D. for($idx *= 2; STOP_AT >= $idx; $idx = 0)
E. while($idx < STOP_AT) do $idx *= 2
6.下边代码中,index.php 如何得到form传递的email的值?
(选择2个答案)
<form action="index.php" method="post">
<input type="text" name="email"/>
</form>
A. $_GET['email']
B. $_POST['email']
C. $_SESSION['text’]
D. $_REQUEST['email']
E. $_POST['text']
7.分析下段代码, 数组 $multi_array的值cat将会被如何引用?
<?php
$multi_array = array("red",
"green",
42 => "blue",
"yellow" => array("apple",
9 => "pear",
"banana",
"orange" => array("dog",
"cat",
"iguana")
)
);
?>
A. $multi_array['yellow']['apple'][0]
B. $multi_array['blue'][0]['orange'][1]
C. $multi_array[3][3][2]
D. $multi_array['yellow']['orange']['cat']
E. $multi_array['yellow']['orange'][1]
8. 如何将一个数组元素的排列顺序反转过来(例如以下代码反转以后的顺序是: array ('d', 'c', 'b', 'a'))? (选择2个答案)
<?php
$array = array ('a', 'b', 'c', 'd');
?>
A. array_flip()
B. array_reverse()
C. sort()
D. rsort()
E. None of the above
9. 请从以下方法中选出最简单的方法来计算一个数组的所有值的和
A. 通过 for 循环
B. 通过 foreach 循环
C. 用 array_intersect 方法
D. 用 the array_sum 方法
E. 用 array_count_values()方法
10. 以下选项哪个不能将 strings $s1 和 $s2 合并成一个单独的string?
A. $s1 + $s2
B. "{$s1}{$s2}"
C. $s1.$s2
D. implode('', array($s1,$s2))
E. All of the above combine the strings
11. 比较两个字符串大小的最好方法是什么?
A. Using the strpos function
B. Using the == operator
C. Using strcasecmp()
D. Using strcmp()
12. 以下哪些表达式返回值为TRUE? (选择2个答案)
A. '1top' == '1'
B. 'top' == 0
C. 'top' === 0
D. 'a' == a
E. 123 == '123'
13.哪个选项会匹配下边的这个正则表达式?
/.*\*123\d/
A. ******123
B. *****_1234
C. ******1234
D. _*123
14. 以下代码的功能是一行一行的读取一个文件并输出,那么在问号处填入哪个方法可以实现这个功能?
<?php
$file = fopen("test", "r");
while(!feof($file)) {
echo ????????????;
}
A. file_get_contents($file)
B. file($file)
C. read_file($file)
D. fgets($file)
E. fread($file)
15.请选出最简单的方法将microtime()函数输出的结果转换成数字型的值
A. $time = implode (' ', microtime());
B. $time = explode (' ', microtime()); $time = $time[0] + $time[1];
C. $time = microtime() + microtime();
D. $time = array_sum (explode (' ', microtime()));
E. None of the above
16. 以下哪些函数的返回值不是时间戳类型的? (选择2个答案)
A. time()
B. date()
C. strtotime()
D. localtime()
E. gmmktime()
17. 以下这些 DBMSs 中,哪个没有PHP内部扩展?
A. MySQL
B. IBM DB/2
C. PostgreSQL
D. Microsoft SQL Server
E. None of the above
18. 以下哪些是正确的PHP stream传送方式 ? (选择2个答案)
A. http
B. STDIO
C. ftp
D. STDOUT
E. stream
19.以下哪个错误无法被标准的错误控制器获取?
A. E_WARNING
B. E_USER_ERROR
C. E_PARSE
D. E_NOTICE
20. trigger_error() 和user_error()的区别是什么?
A. trigger_error() 允许程序抛出系统级错误提示
B. user_error() 允许程序抛出系统级错误提示
C. user_error() 不可用于错误控制
D. trigger_error() 只在PHP5中有效
E. 没有区别
二。简答题(每题4分,共60分)
1.简单描述一下 require(),include,require_once(),include_once()之间的区别
2.php中数据类型分几种,都有哪些数据类型
3.用PHP打印出前一天的时间格式是0000-00-00 00:00:00
4.用PHP打印出这样的时间格式 Feb-02-2008
5.php如何解析xml文件?请举例说明
6.在PHP中,当前脚本的名称(不包括路径和查询字符串)记录在哪个预定义变量中;而链接到当前页面的URL记录在哪个预定义变量中
7.简单描述 asort()、ksort()、rsort()的作用分别是什么?
8.类的属性可以序列化后保存到 session 中,从而以后可以恢复整个类,这要用到的函数是什么
9.isset()和empty()的区别
10.请说明 PHP 中传值与传引用的区别。什么时候传值什么时候传引用?
11.有一个网页地址 http://www.test.com/111.php,如何得到它的内容?
12.写出一个正则表达式,过虑网页上的所有JS/VBS脚本(即把script标记及其内容都去掉):
13.php webservice 是通过什么协议实现的,简单写一下实现方式
14.我们在使用header进行跳转时经常会提示header already sent 这个错误,这是什么原因,该如何解决
15.form中复选框内容提交时,如何操作才能最方便快捷的获得所有内容?