View a printer-optimized version of this page

Zend PHP 5 Certification - Self Test

Posted at July 2, 2007 by Vagharshak Tozalakyan

Zend suggests to take their 8-question self-test and find out whether the Zend PHP 5 Certification Guide can be useful for test-taker to prepare for the PHP Certification exam. The level of difficulty and subject matters are on par with those encountered throughout the actual exam.

Even if you are not going to pass the real PHP Ceritfication exam, I think it will be interesting for you to take the test exam just to find out your abilities. My result was 7 from 8 and what's yours?

Question 1. How can precisely one byte be read from a file, pointed by $fp?

  • fseek($fp, 1)
  • fgets($fp, 1)
  • fgetss($fp, 1)
  • fgetc($fp)
  • All of the above

The right answer is D. Function fseek() sets the file position indicator for the file referenced by handle. Function fgets() reads a string from the file with the length defined as second parameter minus 1 byte. Function fgetss() is the same as fgets() with only difference that it removes all PHP and HTML tags from the string.

Question 2. What object method specifies post-deserialization behavior for an object?

  • __sleep()
  • __wakeup()
  • __set_state()
  • __get()
  • __autoload()

The right answer id B. Function serialize() checks if the class has a function with the "magic name" __sleep. If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. Conversely, unserialize() checks for the presence of a function with the "magic name" __wakeup. If present, this function can reconstruct any resources that the object may have. The __set_state() is called for classes exported by var_export(). The __get() method is used to overload the access to object properties and methods. An __autoload() may be defined and it will automatically called in case you are trying to use a class which hasn't been defined yet.

Question 3. Where does the session extension store the session data by default?

  • SQLite Database
  • MySQL Database
  • Shared Memory
  • File System
  • Session Server

The right answer is D. Function session_set_save_handler() may be called to set the user-level session storage functions which are used for storing the session data in a database or other storage container.

Question 4. Which of the following data types cannot be directly manipulated by the client?

  • Cookie Data
  • Session Data
  • Remote IP Address
  • User Agent

The right answer is B. Sessions are stored on the server-side and session data cannot be directly manipulated by the client as it is possible to change session variables only through a server-side script.

Question 5. What is the difference between isset() and other is_*() functions (is_alpha(), is_number(), etc.)?

  • isset() is a function call and is_*() are not function calls
  • is_*() are language constructs and isset() is not a language construct
  • isset() is a language construct and is_*() are not language constructs
  • is_*() return a value whereas isset() does not

The right answer is C. is_number(), is_integer(), is_float(), etc. are all functions.

Question 6. What will be the value of $b after running the following code?

<?php
$a 
= array('c''b''a');
$b = (array) $a;
?>

  • TRUE
  • array('c', 'b', 'a')
  • array(array('c', 'b', 'a'))
  • None of the above

The right answer is B. First line creates an array and assigns it to $a. Second line brings the $a to array type (although it is already an array) and assigns it to $b. So the $b should be an exact copy of $a.

Question 7. Which of the following function signatures is correct if you want to have classes automatically loaded?

  • function autoload($class_name)
  • function __autoload($class_name, $file)
  • function __autoload($class_name)
  • function _autoload($class_name)
  • function autoload($class_name, $file)

The right answer is C. By calling this function the scripting engine is given a last chance to load the class before PHP fails with an error. Note that all new PHP 5 "magic methods" are starting with double underline.

Question 8. What is the best way to run PHP 4 and PHP 5 side-by-side on the same Apache server?

  • Run one as an Apache module, the other as a CGI binary.
  • Run both as a CGI binary.
  • Just use .php4 for PHP 4, and .php for PHP 5.
  • Use .php for both but use different document roots.

The right answer is A. Although, in my opinion, it is quite controversial.

Comments

View all comments (4)

Comments are moderated. If your comment does not appear immediately, there is no need to submit it again. Please treat others with respect. Comments containing hate speech, obscenity, and personal attacks will not be approved.






Validation code