Zend PHP5认证模拟考试以及答案(一)

1.下面选项中哪些是正确的PHP标记

  1. <SCRIPT LANGUAGE="php">
  2. <!
  3. <%
  4. <?php
  5. <?

答案: A, C, D, E

http://php.net/manual/en/language.basic-syntax.phpmode.php

2. 下面哪些变量是正确的

  1. @$foo
  2. &$variable
  3. ${0×0}
  4. $variable
  5. $0×0

答案: A, B, C, D

http://php.net/manual/en/language.variables.php

3. 在PHP5中,下面哪项能改变数组中每个元素

  1. 循环的时候不能改变每个元素
  2. for($i = 0; $i < count($array); $i++) { /* … */ }
  3. foreach($array as $key => &$val) { /* … */ }
  4. foreach($array as $key => $val) { /* … */ }
  5. while(list($key, $val) = each($array)) { /* … */

答案: C

http://php.net/manual/en/control-structures.foreach.php

PHP5中,你可以使用在变量前加&符号改变数组中的每个元素,不是去复制而是分配值

4. 下面的PHP代码运行后输出结果是什么

<?php
define('FOO', 10);
$array = array(10 => FOO, "FOO" => 20);
print $array[$array[FOO]] * $array["FOO"];
?>
  1. FOO
  2. 100
  3. 200
  4. 20
  5. 10

答案: C

http://www.php.net/manual/en/function.define.php,http://php.net/manual/en/language.constants.php, FOO 是常量, 但“FOO” 是字符串

5. 下面的PHP代码运行后输出结果是什么

<?php
$a = 1;
$b = 2.5;
$c = 0xFF;
$d = $b + $c;
$e = $d * $b;
$f = ($d + $e) % $a;
print ($f + $e);
?>

  1. 643.75
  2. 432
  3. 643
  4. 257
  5. 432.75

答案: A 

http://en.wikipedia.org/wiki/Hexadecimal,http://www.php.net/manual/en/language.operators.arithmetic.php

6. 哪组中$a, $b, $c, 和$d的值能保证以下代码运行后结果$number是3

<?php
$a = null;
$b = null;
$c = null;
$d = null;
if($a && !$b) {
if(!!$c && !$d) {
if($d && ($a || $c)) {
if(!$d && $b) {
$number = 1;
} else {
$number = 2;
}
} else {
$number = 3;
}
} else {
$number = 4;
}
} else {
$number = 5;
}
?>

  1. false, true, true, true
  2. true, false, true, false
  3. true, true, false, false
  4. false, true, true, false
  5. false, false, true, false

答案: B
http://www.php.net/manual/en/language.operators.logical.php : $a && $b – And – TRUE if both $a and $b are TRUE -> ($a && !$b) TRUE then $a is TRUE and $b is FALSE.


7. 下面的PHP代码运行后输出结果是什么

<?php
$string = "111221";
for($i = 0; $i < strlen($string); $i++) {
$current = $string[$i];
$count = 1;
while(isset($string[$i + $count]) && ($string[$i + $count] == $current)) $count++;
$newstring .= "$count{$current}";
$i += $count-1;
}
print $newstring;
?>

  1. 312211
  2. 3312212
  3. 11221221
  4. 221131
  5. 3211122

Answer: A
循环一次while loop就得到了

8. 下面哪个选项能保证用户自定义函数的参数为一个唯一的对象

  1. function myfunction(stdClass $a)
  2. function myfunciton($a = stdClass)
  3. 在函数里面使用函数is_object()
  4. 不能保证传入的参数是对象
  5. function myfunction(Object $a)

答案: C
http://php.net/manual/en/function.is-object.php

9. 当下面的函数传入两个整数的变量$p和$q之后会怎样[下面函数的功能是什么]

<?php
function magic($p, $q) {
return ($q == 0) ? $p : magic($q, $p % $q);
}
?>

  1. 死循环
  2. $p 和$q的值会交换
  3. 判断两个变量是否全是基数或偶数
  4. 计算出两变量的公共除数
  5. 计算两变量的系数

答案:D

10. 下面那个符号是用来判断全等的

  1. !==
  2. instanceof
  3. =
  4. ==
  5. ===

答案: E
http://www.php.net/manual/en/language.operators.comparison.php

11. 下面 ?????? 这部分应该是哪些项才不会报fatal错误

<?php
$a = 1;
$b = 0;
??????
$c = $a / $b;
?>

  1. quit();
  2. die();
  3. stop();
  4. __halt_compiler();
  5. exit();

答案: B, D, E
http://ru.php.net/manual/en/function.die.php,http://php.net/manual/en/function.halt-compiler.php,http://ru.php.net/manual/en/function.exit.php


12. 下面的PHP代码运行后输出结果是什么

<?php
$a = 010;
$b = 0xA;
$c = 2;
print $a + $b + $c;
?>

  1. 20
  2. 22
  3. 18
  4. $a 是非法变量
  5. 2

答案: A
http://en.wikipedia.org/wiki/Octal,http://en.wikipedia.org/wiki/Hexadecimal

13. 下面的PHP代码运行后输出结果是什么

<?php
$a = 20;
function myfunction($b) {
$a = 30;
global $a, $c;
return $c = ($b + $a);
}
print myfunction(40) + $c;
?>

  1. 120
  2. 报错
  3. 60
  4. 70

答案: A
http://php.net/manual/en/language.variables.scope.php

14. 下面 ??????? 这部分填哪项代码能输出“Hello, World!” (单选)

<?php
function myfunction() {
   ???????
   print $string;
}
myfunction("Hello, World!");
?>

  1. 没有合适的代码
  2. $string = $argv[1];
  3. $string = $_ARGV[0];
  4. list($string) = func_get_args();
  5. $string = get_function_args()

答案:D
http://ru.php.net/manual/en/function.func-get-args.php

15. 下面的functions输出结果是什么? (单选)

<?php
function &find_variable(&$one, &$two, &$three) {
   if($one > 10 && $one < 20) return $one;
   if($two > 10 && $two < 20) return $two;
   if($three > 10 && $three < 20) return $three;
}
$one = 2;
$two = 20;
$three = 15;
$var = &find_variable($one, $two, $three);
$var++;
print "1: $one, 2: $two, 3: $three";
?>

  1. 1: 2, 2: 20, 3: 15
  2. 1: 3, 2:21, 3:16
  3. 1: 2, 2:21, 3:15
  4. 1: 3, 2: 20, 3: 15
  5. 1: 2, 2: 20, 3: 16

答案: E
http://www.php.net/manual/en/functions.returning-values.php,http://www.php.net/manual/en/language.references.return.php
http://www.php.net/manual/en/language.references.pass.php

16. 对于任意字符串$mystring, 下面哪项能正确判断出$mystring包含"PHP"这个字符串? (单选)

  1. if(strpos($mystring, «PHP») !== false)
  2. if(!strpos($mystring,»PHP»))
  3. if(strpos($mystring, «PHP») === true)
  4. if(strloc($mystring, «PHP») == true)
  5. if(strloc($mystring, «PHP») === false)

答案: A
http://php.net/manual/en/function.strpos.php: 此函数可能返回布尔值false,也可能会返回等价于false的非布尔值,例如 0或者""
http://www.php.net/manual/en/language.types.boolean.php
http://www.php.net/manual/en/language.operators.comparison.php

17. $a在下面$obj_one 和$obj_two 中运行后结果分别是什么? (单选)

<?php
class myClass {
   private $a;
   public function __construct() {
      $this->a = 10;
   }
   public function printValue() {
      print "The Value is: {$this->a}\n";
   }
   public function changeValue($val, $obj = null) {
      if(is_null($obj)) {
         $this->a = $val;
      } else {
         $obj->a = $val;
      }
   }
   public function getValue() {
      return $this->a;
   }
}
$obj_one = new myClass();
$obj_two = new myClass();
$obj_one->changeValue(20, $obj_two);
$obj_two->changeValue($obj_two->getValue(), $obj_one);
$obj_two->printValue();
$obj_one->printValue();
?>

  1. 10,20
  2. 不能改变另以class的私有成员
  3. 20,20
  4. 10,10
  5. 20,10

答案: C
http://php.net/manual/en/language.oop5.visibility.php
http://php.net/manual/en/language.oop5.references.php

18. 在php的对象中下面哪些可以用来定义成员的访问权限? (选三项)

  1. protected
  2. public
  3. static
  4. private
  5. final

答案: A, B, D
http://php.net/manual/en/language.oop5.visibility.php

19. 那项可以检查两个变($obj1、$obj2)属于同一个实例化对象? (单选)

  1. if($obj1->equals($obj2) && ($obj1 instanceof $obj2))
  2. if($obj1->equals($obj2))
  3. if($obj1 === $obj2)
  4. if($obj1 instance of $obj2)
  5. if($obj1 == $obj2)

Answer: D
http://php.net/manual/en/internals2.opcodes.instanceof.php,http://php.net/manual/en/language.operators.type.php

20. 在 PHP 5中确定是否某个对象是相应类的一个实例的关键词是___,同时要你也可以使用__声明 (Choose 1 answer)

  1. instanceof, is_a
  2. instanceof, type-hinting
  3. type, instanceof
  4. ===, type-hinting
  5. ===, is_a

答案: B
http://php.net/manual/en/internals2.opcodes.instanceof.php,http://php.net/manual/en/language.oop5.typehinting.php

21. 下面的代码有什么问题? (单选)

<?php
function duplicate($obj) {
   $newObj = $obj;
   return $newObj;
}
$a = new MyClass();
$a_copy = duplicate($a);
$a->setValue(10);
$a_copy->setValue(20);
?>

  1. 必须使用return &$newObj
  2. 没有错误
  3. duplicate() 须是引用参数
  4. 需用克隆复制出另一个对象
  5. duplicate() 须返回一个引用值

答案: D
http://php.net/manual/en/language.oop5.cloning.php

22. 在克隆一个对象的时候你怎么去修改复制的对象? (单选)

  1. 把魔法函数放在构造函数里输出值
  2. Implment 自定义函数来实现复制对象
  3. Implement对象的 __clone() 方法
  4. Implement  __get() 和__set() 方法methods with the correct logic
  5. 使用正确的魔法来Implement  __copy() 方法

Answer: C
http://php.net/manual/en/language.oop5.cloning.php

23. 静态方法与普通方法有什么不一样? (Choose 1 answer)

  1. 只能用::的方法调用,而不是实例化
  2. 伪变量$this不能调用它
  3. 实例化的时候不能调用
  4. 对自己的属性没有访问权限
  5. 没区别

Answer: A
http://php.net/manual/en/language.oop5.static.php:  被声明为静态的成员或是方法是不需要实例化就能调用,带方法内部也不支持伪变量$this。

24. What is the output of the following script? (Choose 1 answer)
<?php
class ClassOne {
   protected $a = 10;
   public function changeValue($b) {
      $this->a = $b;
   }
}
class ClassTwo extends ClassOne {
   protected $b = 10;
   public function changeValue($b) {
      $this->b = 10;
      parent::changeValue($this->a + $this->b);
   }
   public function displayValues() {
      print "a: {$this->a}, b: {$this->b}\n";
   }
}
$obj = new ClassTwo();
$obj->changeValue(20);
$obj->changeValue(10);
$obj->displayValues();
?>

  1. a: 30, b: 30
  2. a: 30, b: 20
  3. a: 30, b: 10
  4. a: 20, b: 20
  5. a: 10, b: 10

Answer: C
http://php.net/manual/en/language.oop5.visibility.php

25. 下面哪个是定义接口的关键词. (Choose 1 answer)

  1. final
  2. protected
  3. incomplete
  4. abstract
  5. implements

Answer: D
http://php.net/manual/en/language.oop5.abstract.php

26. To ensure that a given object has a particular set of methods, you must provide a method list in the form of an________ and then attach it as part of your class using the ________ keyword. (Choose 1 answer)

  1. array, interface
  2. interface, implements
  3. interface, extends
  4. instance, implements
  5. access-list, instance

Answer: B
http://php.net/manual/en/language.oop5.interfaces.php

27. Type-hinting and the instanceof keyword can be used to check what types of things about variables? (Choose 3 answers)

  1. If a particular child class extends from it
  2. If they are an instance of a particular interface
  3. If they are an abstract class
  4. If they have a particular parent class
  5. If they are an instance of a particular class

Answer: B, D, E
http://php.net/manual/en/language.operators.type.php: Example #4, Example #2, Example #1 respectively

28. In PHP 5's object model, a class can have multiple ______ but only a single direct. (Choose 1 answer)

  1. None of the above
  2. interfaces, child
  3. children, interface
  4. interfaces, parent
  5. parents, interface

Answer: D
http://php.net/manual/en/language.oop5.interfaces.php: Example #3 Multiple interface inheritance,http://php.net/manual/en/keyword.extends.php: An extended class is always dependent on a single base class, that is, multiple inheritance is not supported.

29. What three special methods can be used to perform special logic in the event a particular accessed method or member variable is not found? (Choose 3 answers)

  1. __get($variable)
  2. __call($method, $params)
  3. __get($method)
  4. __set($variable, $value)
  5. __call($method)

Answer: A, B, D
http://php.net/manual/en/language.oop5.overloading.php

30. The _______ method will be called automatically when an object is represented as a string. (Choose 1 answer)

  1. getString()
  2. __get()
  3. __value()
  4. __toString()
  5. __getString()

Answer: D
http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring

31. When an object is serialized, which method will be called, automatically, providing your object with an opportunity to close any resources or otherwise prepare to be serialized? (Choose 1 answer)

  1. __destroy()
  2. __serialize()
  3. __destruct()
  4. __shutdown()
  5. __sleep()

Answer: E
http://php.net/manual/en/function.serialize.php

32. What is the output of the following code? (Choose 1 answer)
<?php
class MyException extends Exception {}
class AnotherException extends MyException {}
class Foo {
   public function something() {
      throw new AnotherException();
   }
   public function somethingElse() {
      throw new MyException();
   }
}
$a = new Foo();
try {
   try {
      $a->something();
   } catch(AnotherException $e) {
      $a->somethingElse();
   } catch(MyException $e) {
      print "Caught Exception";
   }
} catch(Exception $e) {
   print "Didn't catch the Exception!";
}
?>

  1. «Caught Exception» followed by «Didn't catch the Exception!»
  2. A fatal error for an uncaught exception
  3. «Didn't catch the Exception!»
  4. «Didn't catch the Exception!» followed by a fatal error
  5. «Caught Exception»

Answer: C
http://php.net/manual/en/language.exceptions.php,http://stackoverflow.com/questions/2586608/confused-by-this-php-exception-try-catch-nesting

33. Which two internal PHP interfaces provide functionality which allow you to treat an object like an array? (Choose 2 answers)

  1. iteration
  2. arrayaccess
  3. objectarray
  4. iterator
  5. array

Answer: B, D
http://php.net/manual/en/class.arrayaccess.php,http://php.net/manual/en/class.iterator.php

34. Which php.ini directive should be disabled to prevent the execution of a remote PHP script via an include or require construct? (Choose 1 answer)

  1. You cannot disable remote PHP script execution
  2. curl.enabled
  3. allow_remote_url
  4. allow_url_fopen
  5. allow_require

Answer: D
http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

35. When attempting to prevent a cross-site scripting attack, which of the following is most important? (Choose 1 answer)

  1. Not writing Javascript on the fly using PHP
  2. Filtering Output used in form data
  3. Filtering Output used in database transactions
  4. Writing careful Javascript
  5. Filtering all input

Answer: E

36. Which of the following php.ini directives should be disabled to improve the outward security of your application? (Choose 4 answers)

  1. safe_mode
  2. magic_quotes_gpc
  3. register_globals
  4. display_errors
  5. allow_url_fopen

Answer: B, C, D, E
http://php.net/manual/en/features.safe-mode.php

37. Which of the following list of potential data sources should be considered trusted? (Choose 1 answer)

  1. None of the above
  2. $_ENV
  3. $_GET
  4. $_COOKIE
  5. $_SERVER

Answer: A

38. What is the best way to ensure the distinction between filtered / trusted and unfiltered / untrusted data? (Choose 1 answer)

  1. None of the above
  2. Never trust any data from the user
  3. Enable built-in security features such as magic_quotes_gpc and safe_mode
  4. Always filter all incoming data
  5. Use PHP 5's tainted mode

Answer: D
http://devzone.zend.com/article/1113

39. Consider the following code, what potential security hole would this code snippet produce: (Choose 1 answer)
<?php
session_start();
if(!empty($_REQUEST['id']) && !empty($_REQUEST['quantity'])) {
   $id = scrub_id($_REQUEST['id']);
   $quantity = scrub_quantity($_REQUEST['quantity'])
   $_SESSION['cart'][] = array('id' => $id, 'quantity' => $quantity)
}
/* .... */
?>

  1. Cross-Site Scripting Attack
  2. There is no security hole in this code
  3. Code Injection
  4. SQL Injection
  5. Cross-Site Request Forgery

Answer: E
http://en.wikipedia.org/wiki/Cross-site_request_forgery

40. What is the best measure one can take to prevent a cross-site request forgery? (Choose 1 answer)

  1. Disallow requests from outside hosts
  2. Add a secret token to all form submissions
  3. Turn off allow_url_fopen in php.ini
  4. Filter all output
  5. Filter all input

Answer:B
http://en.wikipedia.org/wiki/Cross-site_request_forgery#Prevention

41. Consider the following code, which of the following values of $_GET['url'] would cause session fixation? (Choose 1 answer)
<?php
header("Location: {$_GET['url']}");
?>

  1. Session Fixation is not possible with this code snippet
  2. http://www.zend.com/?PHPSESSID=123
  3. PHPSESSID%611243
  4. Set-Cookie%3A+PHPSESSID%611234
  5. http%3A%2F%2Fwww.zend.com%2F%0D%0ASet-Cookie%3A+PHPSESSID%611234

Answer: B
http://www.php.net/manual/en/session.idpassing.php

42. When implementing a permissions system for your Web site, what should always be done with regards to the session? (Choose 1 answer)

  1. None of the above
  2. You should not implement permission systems using sessions
  3. Sessions should be cleared of all data and re-populated
  4. The session key should be regenerated
  5. The session should be destroyed

Answer: D
http://www.php.net/manual/en/function.session-regenerate-id.php

43. Which of the following is not valid syntax for creating a new array key? (Choose 1 answer)

  1. $a[] = «value»;
  2. $a{} = «value»;
  3. $a[0] = «value»;
  4. $a{0} = «value»;
  5. $a[$b = 0] = «value»;

Answer: B
http://php.net/manual/en/language.types.array.php

44. Which of the following functions will sort an array in ascending order by value, while preserving key associations? (Choose 1 answer)

  1. asort()
  2. usort()
  3. krsort()
  4. ksort()
  5. sort()

Answer: A
http://php.net/manual/en/function.asort.php — sort an array and maintain index association.

45. What is the output of the following code block? (Choose 1 answer)
<?php
$a = "The quick brown fox jumped over the lazy dog.";
$b = array_map("strtoupper", explode(" ", $a));
foreach($b as $value) {
   print "$value ";
}
?>

  1. THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.
  2. A PHP Error
  3. Array Array Array Array Array Array Array Array Array

Answer: A
http://php.net/manual/en/function.array-map.php

46. Which from the following list is not an appropriate use of an array? (Choose 1 answer)

  1. As a list
  2. All of these uses are valid
  3. As a Lookup Table
  4. A Stack
  5. As a hash table

Answer: B
http://php.net/manual/en/language.types.array.php: This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more.

47. What is the output of this code snippet? (Choose 1 answer)
<?php
$a = array(0.001 => 'b', .1 => 'c');
print_r($a);
?>

  1. An empty array
  2. 0.001 => 'b', .1 => c
  3. 0 => 'c'
  4. '0.001' => 'b', '0.1' => c'
  5. A Syntax Error

Answer: C
http://php.net/manual/en/language.types.array.php :Floats in key are truncated to integer.

48. Which of the following functions could be used to break a string into an array? (Choose 3 answers)

  1. array_split()
  2. split()
  3. string_split()
  4. preg_match_all()
  5. explode()

Answer: B, D, E
http://ru.php.net/manual/en/function.split.php,http://ru.php.net/manual/en/function.preg-match-all.php,http://ru.php.net/manual/en/function.explode.php

49. If you wanted a variable containing the letters A through Z, that allowed you to access each letter independently, which of the following approaches could you use? (Choose 3 answers)

  1. $str = «ABCDEFGHIJKLMNOPQRSTUVWXYZ»;
  2. range('A', 'Z');
  3. explode(«», «ABCDEFGHIJKLMNOPQRSTUVWXYZ»);
  4. You would use the ALPHA_ARRAY constant
  5. None of the above

Answer: A, B, C (but C is error in mock test, see manual about delimeter)
http://ru.php.net/manual/en/function.range.php,http://ru.php.net/manual/en/function.explode.php (Warning: explode(): Empty delimiter.)

50. What is the output of the following code block? (Choose 1 answer)
<?php
$array = array(1 => 0, 2, 3, 4);
array_splice($array, 3, count($array), array_merge(array('x'), array_slice($array, 3)));
print_r($array);
?>

  1. 1 => 1, 2 => 2, 3 => x, 4=> 4
  2. 0 => 1, 2 => 2, 3 => 3, 4 => 4, x => 3
  3. 0 => 0, 1=> 2, 2 => 3, 3 => x, 4 => 4
  4. 0 => x, 1 => 0, 2 => 1, 3=> 2, 4=>3
  5. 1 => 1, 3 => x, 2 => 2, 4 => 4

Answer: C
http://ru.php.net/manual/en/function.array-slice.php,http://ru.php.net/manual/en/function.array-merge.php,http://ru.php.net/manual/en/function.array-splice.php

51. Which function would you use to add an element to the beginning of an array? (Choose 1 answer)

  1. array_shift()
  2. array_push();
  3. $array[0] = «value»;
  4. array_unshift()
  5. array_pop();

Answer: D
http://ru.php.net/manual/en/function.array-unshift.php

52. Which key will not be displayed from the following code block? (Choose 1 answer)
<?php
$array = array('a' => 'John',
'b' => 'Coggeshall',
'c' => array('d' => 'John',
'e' => 'Smith'));
function display($item, $key) {
   print "$key => $item\n";
}
array_walk_recursive($array, "display");
?>

  1. d
  2. c
  3. b
  4. a
  5. They all will be displayed

Answer: B
http://ru.php.net/manual/en/function.array-walk-recursive.php

53. What is the result of the following code snippet? (Choose 1 answer)
<?php
$array = array('a' => 'John',
'b' => 'Coggeshall',
'c' => array('d' => 'John',
'e' => 'Smith'));
function something($array) {
   extract($array);
   return $c['e'];
}
print something($array);
?>

  1. Smith
  2. A PHP Warning
  3. Coggeshall
  4. NULL
  5. Array

Answer: A
http://ru.php.net/manual/en/function.extract.php

54. What should go in the missing line ????? below to produce the output shown? (Choose 1 answer)
<?php
$array_one = array(1,2,3,4,5);
$array_two = array('A', 'B', 'C', 'D', 'E');
???????
print_r($array_three);
?>

Result:
Array
(
[5] => A
[4] => B
[3] => C
[2] => D
[1] => E
)

  1. $array_three = array_merge(array_reverse($array_one), $array_two);
  2. $array_three = array_combine($array_one, $array_two);
  3. $array_three = array_combine(array_reverse($array_one), $array_two);
  4. $array_three = array_merge($array_one, $array_two);
  5. $array_three = array_reverse($array_one) + $array_two;

Answer: C
http://ru.php.net/manual/en/function.array-combine.php,http://ru.php.net/manual/en/function.array-reverse.php

55. Which of the following functions are used with the internal array pointer to accomplish an action? (Choose 4 answers)

  1. key
  2. forward
  3. prev
  4. current
  5. next

Answer: A, C, D, E
http://php.net/manual/en/function.key.php, http://php.net/manual/en/function.prev.php, http://php.net/manual/en/function.current.php, http://php.net/manual/en/function.next.php

56. Given the following array, the fastest way to determine the total number a particular value appears in the array is to use which function: (Choose 1 answer)
$array = array(1,1,2,3,4,4,5,6,6,6,6,3,2,2,2);

  1. array_total_values
  2. array_count_values
  3. A foreach loop
  4. count
  5. a for loop

Answer: B
http://ru.php.net/manual/en/function.array-count-values.php

57. The ____ construct is particularly useful to assign your own variable names to values within an array. (Choose 1 answer)

  1. array_get_variables
  2. current
  3. each
  4. import_variables
  5. list

Answer: E
http://ru.php.net/manual/en/function.list.php

58. The following code snippet displays what for the resultant array? (Choose 1 answer)
<?php
$a = array(1 => 0, 3 => 2, 4 => 6);
$b = array(3 => 1, 4 => 3, 6 => 4);
print_r(array_intersect($a, $b));
?>

  1. 1 => 0
  2. 1 => 3, 3 => 1, 4 => 3
  3. 3 => 1, 3=> 2, 4 => 3, 4=> 6
  4. 1 => 0, 3 => 2, 4 => 6
  5. An empty Array

http://ru.php.net/manual/en/function.array-intersect.php

59. Which of the following are not valid ways to embed a variable into a string? (Choose 1 answer)

  1. $a = «Value: $value->getValue()»;
  2. $a = «Value: {$value}»;
  3. $a = 'Value: $value';
  4. $a = «Value: $value»;
  5. $a = «Value: {$value['val']}»;

Answer: A, C
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double

60. What variable reference would go in the spots indcated by ????? in the code segment below? (Choose 1 answer)
<?php
$msg = "The Quick Brown Foxed Jumped Over the Lazy Dog";
$state = true;
$retval = "";
for($i = 0; (isset(??????)); $i++) {
   if($state) {
      $retval .= strtolower(?????);
   } else {
      $retval .= strtoupper(?????);
   }
$state = !$state;
}
print $retval;
?>

  1. $msg{$i}
  2. ord($msg);
  3. chr($msg);
  4. substr($msg, $i, 2);

Answer: A
http://ru.php.net/manual/en/function.isset.php


继续更新。。。

原文:Zend PHP5 Certification Mock Exam Sample Questions — 1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值