Zend认证试题第一章(PHP Programming Basics)
时间:2007-12-25
来源:互联网
ZendChina官方:最重要的是要您要掌握好基础知识。这些知识是需要您一直去关注和学习的,因为它们是学习PHP语言的根基。考试中您没有准备到的部分也可能是您日常程序开发中不会接触到的知识,但是本章中的问题还是需要得到您的重视,毕竟,如果您对最基本知识了解不够,对于您更深入的学习和开发也会带来诸多不便。
1、Choose the selection that best matches the following statements:
PHP is a _____ scripting language based on the ____ engine. It is primarily used to develop dynamic
_____ content, although it can be used to generate ____ documents(among others) as well.
A.Dynamic, PHP, Database, HTML
B.Embedded, Zend, HTML, XML
C.Perl-based, PHP, Web, Static
D.Embedded, Zend, Docbook, MySQL
E.Zend-based, PHP, Image, HTML
2、Which of the following tags is not a valid way to begin and end a PHP code block?
A.<% %>
B.<? ?>
C.<?= ?>
D.<! !>
E.<?php ?>
3、Which of the following is not valid PHP code?
A.$_10
B.${“MyVar”}
C.&$something
D.$10_somethings
E.$aVaR
4、What is displayed when the following script is executed? 复制PHP内容到剪贴板 PHP代码:<?php
define(myvalue, "10");
$myarray[10] = "Dog";
$myarray[] = "Human";
$myarray['myvalue'] = "Cat";
$myarray["Dog"] = "Cat";
print "The value is: ";
print $myarray[myvalue]."\n";
?>
A.The value is: Dog
B.The value is: Cat
C.The value is: Human
D.The value is: 10
E.Dog
5、What is the difference between print() and echo()?
A.print() can be used as part of an expression, while echo() can’t
B.echo() can be used as part of an expression, while print() can’t
C.echo() can be used in the CLI version of PHP, while print() can’t
D.print() can be used in the CLI version of PHP, while echo() can’t
E.There’s no difference: both functions print out some text!
6、What is the output of the following script? 复制PHP内容到剪贴板 PHP代码:<?php
$a = 10;
$b = 20;
$c = 4;
$d = 8;
$e = 1.0;
$f = $c + $d * 2;
$g = $f % 20;
$h = $b - $a + $c + 2;
$i = $h << $c;
$j = $i * $e;
print $j;
?>
A. 128
B. 42
C. 242.0
D. 256
E. 342
7、Which values should be assigned to the variables $a, $b and $c in order for the following script to display the string Hello, World!? 复制PHP内容到剪贴板 PHP代码:<?php
$string = "Hello, World!";
$a = ?;
$b = ?;
$c = ?;
if($a) {
if($b && !$c) {
echo "Goodbye Cruel World!";
} else if(!$b && !$c) {
echo "Nothing here";
}
} else {
if(!$b) {
if(!$a && (!$b && $c)) {
echo "Hello, World!";
} else {
echo "Goodbye World!";
}
} else {
echo "Not quite.";
}
}
?>
A. False, True, False
B. True, True, False
C. False, True, True
D. False, False, True
E. True, True, True
8、What will the following script output? 复制PHP内容到剪贴板 PHP代码:<?php
$array = '0123456789ABCDEFG';
$s = '';
for ($i = 1; $i < 50; $i++) {
$s .= $array[rand(0,strlen ($array) - 1)];
}
echo $s;
?>
A. A string of 50 random characters
B. A string of 49 copies of the same character, because the random number generator has not been
initialized
C. A string of 49 random characters
D. Nothing, because $array is not an array
E. A string of 49 ‘G’ characters
9、Which language construct can best represent the following series of if conditionals? 复制PHP内容到剪贴板 PHP代码:<?php
if($a == 'a') {
somefunction();
} else if ($a == 'b') {
anotherfunction();
} else if ($a == 'c') {
dosomething();
} else {
donothing();
}
?>
A. A switch statement without a default case
B. A recursive function call
C. A while statement
D. It is the only representation of this logic
E. A switch statement using a default case
10、What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do? 复制PHP内容到剪贴板 PHP代码:<?php
$myarray = array ("My String",
"Another String",
"Hi, Mom!");
?>
A. Using a for loop
B. Using a foreach loop
C. Using a while loop
D. Using a do…while loop
E. There is no way to accomplish this goal
11、Consider the following segment of code: 复制PHP内容到剪贴板 PHP代码:<?php
define("STOP_AT", 1024);
$result = array();
/* Missing code */
{
$result[] = $idx;
}
print_r($result);
?>
What should go in the marked segment to produce the following array output? 复制PHP内容到剪贴板 PHP代码: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
12、Choose the appropriate function declaration for the user-defined function is_leap(). Assume
that, if not otherwise defined, the is_leap function uses the year 2000 as a default value: 复制PHP内容到剪贴板 PHP代码:<?php
/* Function declaration here */
{
$is_leap = (!($year %4) && (($year % 100) ||
!($year % 400)));
return $is_leap;
}
var_dump(is_leap(1987)); /* Displays false */
var_dump(is_leap()); /* Displays true */
?>
A. function is_leap($year = 2000)
B. is_leap($year default 2000)
C. function is_leap($year default 2000)
D. function is_leap($year)
E. function is_leap(2000 = $year)
13、What is the value displayed when the following is executed? Assume that the code was
executed using the following URL:
testscript.php?c=25 复制PHP内容到剪贴板 PHP代码:<?php
function process($c, $d = 25)
{
global $e;
$retval = $c + $d - $_GET['c'] - $e;
return $retval;
}
$e = 10;
echo process(5);
?>
A. 25
B. -5
C. 10
D. 5
E. 0
14、Consider the following script: 复制PHP内容到剪贴板 PHP代码:<?php
function myfunction($a, $b = true)
{
if($a && !$b) {
echo "Hello, World!\n";
}
}
$s = array(0 => "my",
1 => "call",
2 => '$function',
3 => ' ',
4 => "function",
5 => '$a',
6 => '$b',
7 => 'a',
8 => 'b',
9 => '');
$a = true;
$b = false;
/* Group A */
$name = $s[?].$s[?].$s[?].$s[?].$s[?].$s[?];
/* Group B */
$name(${$s[?]}, ${$s[?]});
?>
Each ? in the above script represents an integer index against the $s array. In order to
display the Hello, World! string when executed, what must the missing integer indexes be?
A. Group A: 4,3,0,4,9,9 Group B: 7,8
B. Group A: 1,3,0,4,9,9 Group B: 7,6
C. Group A: 1,3,2,3,0,4 Group B: 5,8
D. Group A: 0,4,9,9,9,9 Group B: 7,8
E. Group A: 4,3,0,4,9,9 Group B: 7,8
15、Run-time inclusion of a PHP script is performed using the ________ construct, while compile-time
inclusion of PHP scripts is performed using the _______ construct.
A. include_once, include
B. require, include
C. require_once, include
D. include, require
E. All of the above are correct
16、Under what circumstance is it impossible to assign a default value to a parameter while declaring a
function?
A. When the parameter is Boolean
B. When the function is being declared as a member of a class
C. When the parameter is being declared as passed by reference
D. When the function contains only one parameter
E. Never
17、The ____ operator returns True if either of its operands can be evaluated as True, but not both.
Your Answer: ____________________________
18、How does the identity operator === compare two values?
A. It converts them to a common compatible data type and then compares the resulting values
B. It returns True only if they are both of the same type and value
C. If the two values are strings, it performs a lexical comparison
D. It bases its comparison on the C strcmp function exclusively
E. It converts both values to strings and compares them
19、Which of the following expressions multiply the value of the integer variable $a by 4?(Choose 2)
A. $a *= pow (2, 2);
B. $a >>= 2;
C. $a <<= 2;
D. $a += $a + $a;
E. None of the above
20、How can a script come to a clean termination?
A. When exit() is called
B. When the execution reaches the end of the current file
C. When PHP crashes
D. When Apache terminates because of a system problem
答案附在下面,方便大家参考。
ZendChina - Zend认证试题第一章
1、Choose the selection that best matches the following statements:
PHP is a _____ scripting language based on the ____ engine. It is primarily used to develop dynamic
_____ content, although it can be used to generate ____ documents(among others) as well.
A.Dynamic, PHP, Database, HTML
B.Embedded, Zend, HTML, XML
C.Perl-based, PHP, Web, Static
D.Embedded, Zend, Docbook, MySQL
E.Zend-based, PHP, Image, HTML
2、Which of the following tags is not a valid way to begin and end a PHP code block?
A.<% %>
B.<? ?>
C.<?= ?>
D.<! !>
E.<?php ?>
3、Which of the following is not valid PHP code?
A.$_10
B.${“MyVar”}
C.&$something
D.$10_somethings
E.$aVaR
4、What is displayed when the following script is executed? 复制PHP内容到剪贴板 PHP代码:<?php
define(myvalue, "10");
$myarray[10] = "Dog";
$myarray[] = "Human";
$myarray['myvalue'] = "Cat";
$myarray["Dog"] = "Cat";
print "The value is: ";
print $myarray[myvalue]."\n";
?>
A.The value is: Dog
B.The value is: Cat
C.The value is: Human
D.The value is: 10
E.Dog
5、What is the difference between print() and echo()?
A.print() can be used as part of an expression, while echo() can’t
B.echo() can be used as part of an expression, while print() can’t
C.echo() can be used in the CLI version of PHP, while print() can’t
D.print() can be used in the CLI version of PHP, while echo() can’t
E.There’s no difference: both functions print out some text!
6、What is the output of the following script? 复制PHP内容到剪贴板 PHP代码:<?php
$a = 10;
$b = 20;
$c = 4;
$d = 8;
$e = 1.0;
$f = $c + $d * 2;
$g = $f % 20;
$h = $b - $a + $c + 2;
$i = $h << $c;
$j = $i * $e;
print $j;
?>
A. 128
B. 42
C. 242.0
D. 256
E. 342
7、Which values should be assigned to the variables $a, $b and $c in order for the following script to display the string Hello, World!? 复制PHP内容到剪贴板 PHP代码:<?php
$string = "Hello, World!";
$a = ?;
$b = ?;
$c = ?;
if($a) {
if($b && !$c) {
echo "Goodbye Cruel World!";
} else if(!$b && !$c) {
echo "Nothing here";
}
} else {
if(!$b) {
if(!$a && (!$b && $c)) {
echo "Hello, World!";
} else {
echo "Goodbye World!";
}
} else {
echo "Not quite.";
}
}
?>
A. False, True, False
B. True, True, False
C. False, True, True
D. False, False, True
E. True, True, True
8、What will the following script output? 复制PHP内容到剪贴板 PHP代码:<?php
$array = '0123456789ABCDEFG';
$s = '';
for ($i = 1; $i < 50; $i++) {
$s .= $array[rand(0,strlen ($array) - 1)];
}
echo $s;
?>
A. A string of 50 random characters
B. A string of 49 copies of the same character, because the random number generator has not been
initialized
C. A string of 49 random characters
D. Nothing, because $array is not an array
E. A string of 49 ‘G’ characters
9、Which language construct can best represent the following series of if conditionals? 复制PHP内容到剪贴板 PHP代码:<?php
if($a == 'a') {
somefunction();
} else if ($a == 'b') {
anotherfunction();
} else if ($a == 'c') {
dosomething();
} else {
donothing();
}
?>
A. A switch statement without a default case
B. A recursive function call
C. A while statement
D. It is the only representation of this logic
E. A switch statement using a default case
10、What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do? 复制PHP内容到剪贴板 PHP代码:<?php
$myarray = array ("My String",
"Another String",
"Hi, Mom!");
?>
A. Using a for loop
B. Using a foreach loop
C. Using a while loop
D. Using a do…while loop
E. There is no way to accomplish this goal
11、Consider the following segment of code: 复制PHP内容到剪贴板 PHP代码:<?php
define("STOP_AT", 1024);
$result = array();
/* Missing code */
{
$result[] = $idx;
}
print_r($result);
?>
What should go in the marked segment to produce the following array output? 复制PHP内容到剪贴板 PHP代码: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
12、Choose the appropriate function declaration for the user-defined function is_leap(). Assume
that, if not otherwise defined, the is_leap function uses the year 2000 as a default value: 复制PHP内容到剪贴板 PHP代码:<?php
/* Function declaration here */
{
$is_leap = (!($year %4) && (($year % 100) ||
!($year % 400)));
return $is_leap;
}
var_dump(is_leap(1987)); /* Displays false */
var_dump(is_leap()); /* Displays true */
?>
A. function is_leap($year = 2000)
B. is_leap($year default 2000)
C. function is_leap($year default 2000)
D. function is_leap($year)
E. function is_leap(2000 = $year)
13、What is the value displayed when the following is executed? Assume that the code was
executed using the following URL:
testscript.php?c=25 复制PHP内容到剪贴板 PHP代码:<?php
function process($c, $d = 25)
{
global $e;
$retval = $c + $d - $_GET['c'] - $e;
return $retval;
}
$e = 10;
echo process(5);
?>
A. 25
B. -5
C. 10
D. 5
E. 0
14、Consider the following script: 复制PHP内容到剪贴板 PHP代码:<?php
function myfunction($a, $b = true)
{
if($a && !$b) {
echo "Hello, World!\n";
}
}
$s = array(0 => "my",
1 => "call",
2 => '$function',
3 => ' ',
4 => "function",
5 => '$a',
6 => '$b',
7 => 'a',
8 => 'b',
9 => '');
$a = true;
$b = false;
/* Group A */
$name = $s[?].$s[?].$s[?].$s[?].$s[?].$s[?];
/* Group B */
$name(${$s[?]}, ${$s[?]});
?>
Each ? in the above script represents an integer index against the $s array. In order to
display the Hello, World! string when executed, what must the missing integer indexes be?
A. Group A: 4,3,0,4,9,9 Group B: 7,8
B. Group A: 1,3,0,4,9,9 Group B: 7,6
C. Group A: 1,3,2,3,0,4 Group B: 5,8
D. Group A: 0,4,9,9,9,9 Group B: 7,8
E. Group A: 4,3,0,4,9,9 Group B: 7,8
15、Run-time inclusion of a PHP script is performed using the ________ construct, while compile-time
inclusion of PHP scripts is performed using the _______ construct.
A. include_once, include
B. require, include
C. require_once, include
D. include, require
E. All of the above are correct
16、Under what circumstance is it impossible to assign a default value to a parameter while declaring a
function?
A. When the parameter is Boolean
B. When the function is being declared as a member of a class
C. When the parameter is being declared as passed by reference
D. When the function contains only one parameter
E. Never
17、The ____ operator returns True if either of its operands can be evaluated as True, but not both.
Your Answer: ____________________________
18、How does the identity operator === compare two values?
A. It converts them to a common compatible data type and then compares the resulting values
B. It returns True only if they are both of the same type and value
C. If the two values are strings, it performs a lexical comparison
D. It bases its comparison on the C strcmp function exclusively
E. It converts both values to strings and compares them
19、Which of the following expressions multiply the value of the integer variable $a by 4?(Choose 2)
A. $a *= pow (2, 2);
B. $a >>= 2;
C. $a <<= 2;
D. $a += $a + $a;
E. None of the above
20、How can a script come to a clean termination?
A. When exit() is called
B. When the execution reaches the end of the current file
C. When PHP crashes
D. When Apache terminates because of a system problem
答案附在下面,方便大家参考。
ZendChina - Zend认证试题第一章
作者: PHPChina 发布时间: 2007-12-25
第4题就有点//....
作者: zhaofei299 发布时间: 2007-12-25
4. The important thing to note here is that the $myarray array’s key value is being referenced without quotes around it. Because of this, the key being accessed is not the myvalue string but the value represented by the myvalue constant. Hence, it is equivalent to accessing $myarray[10], which is Dog, and Answer A is correct.
作者: RICHARD 发布时间: 2008-01-03
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28