PHP 基础测试题(6~10)

网眼 2009-03-19 22:09:46 回复 置顶 修改 删除
6. What is the output of the following script?

$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!?

$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?

$array = '0123456789ABCDEFG';
$s = '';
for ($i = 1; $i < 50; $i++) {
$s .= $array[rand(0,strlen ($array) - 1)];
}
echo $s;
?>
16
PHP Programming Basics
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?

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?

$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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值