Login

Some ZCE Mock Exam Questions

Some questions from the Zend Certified Engineer (ZCE) Mock Exams

« «« Seite 1 von 2 »» »

You'll find my (!) answers on the next page. Have fun!

Question 1

What are the primary benefits of object oriented programming?

Answers: (choose 3)

  • Maintainability
  • Execution Speed
  • Encapsulation
  • Code Reuse

Question 2

The _____ keyword is used to block any overriding of a class/method by a subclass.

Answers:

  • static
  • None of the above
  • protected
  • final
  • private

Question 3

Event-based XML parsing is an example of which parsing model?

Answers:

  • SAX
  • DOM
  • XML Object Mapping
  • XPath
  • XQuery

Question 4

Which functions would be needed to translate the following string:

I love PHP 5

to the following?

5 PHP EVOL I

Answers: (choose 2)

  • mirror()
  • strtoupper()
  • toupper()
  • str_reverse()
  • strrev()

Question 5

Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?

Answers: (choose 2)

  • iteration
  • arrayaccess
  • objectarray
  • iterator
  • array

Question 6

Consider the following code snippet:

$query = "INSERT INTO mytable 
          (myinteger, mydouble, myblob, myvarchar)
          VALUES (?, ?, ?, ?)";
$statement = mysqli_prepare($link, $query);
	
if(!$statement)
{
  die(mysqli_error($link));
}
	
/* The variables being bound to by MySQLi
   don't need to exist prior to binding */
mysqli_bind_param($statement, "idbs",
  $myinteger, $mydouble, $myblob, $myvarchar);
	
/* ???????????? */ 
	
/* execute the query, using the variables as defined. */
	
if(!mysqli_execute($statement))
{
  die(mysqli_error($link));
}

Assuming this snippet is a smaller part of a correctly written script, what actions must occur in place of the ????? in the above code snippet to insert a row with the following values: 10, 20.2, foo, string ?

Answer...

  • A transaction must be begun and the variables must be assigned
  • Each value must be assigned prior to calling mysqli_bind_param(), and thus nothing should be done
  • Use mysqli_bind_value() to assign each of the values
  • Assign $myinteger, $mydouble, $myblob, $myvarchar the proper values

Question 7

Given the string:

$var = "john@php.net";

Which of the following will extract the TLD (top level domain) of ".net" from the string?

Answer...

  • strstr($var, strpos($var, "."));
  • substr($var, strpos($var, "@"));
  • substr($var, strstr($var, "."));
  • substr($var, strpos($var, ".") + 1);
  • substr($var, strpos($var, "."));

Question 8

The ____ construct is particularly useful to assign your own variable names to values within an array.

Answer...

  • array_get_variables
  • current
  • each
  • import_variables
  • list

Question 9

Given the following XML document in a SimpleXML object:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>XML Example</title>
  </head>
  <body>
    <p>
      Moved to &lt;<a href="http://example.org/">http://www.example.org/</a>.&gt;
      <br/>
    </p>
  </body>
</html>

Select the proper statement below which will display the HREF attribute of the anchor tag.

Answer...

  • $sxe->body->p[0]->a[1]['href']
  • $sxe->body->p->a->href
  • $sxe->body->p->a['href']
  • $sxe['body']['p'][0]['a']['href']
  • $sxe->body->p[1]->a['href']

Question 10

Consider the following script:

$dom = new DOMDOcument();
$dom->load("myxmlfile.xml");
foreach($dom->documentElement->childNodes as $child)
{
  if(($child->nodeType == XML_ELEMENT_NODE) &&
      $child->nodeName == "item")
  {
    foreach($child->childNodes as $item)
    {
      if(($item->nodeType == XML_ELEMENT_NODE) &&
         ($item->nodeName == "title"))
      {
        print "$item->firstChild->data\n";
      }
    }
  }
}

Assuming the referenced XML document exists and matches the parsing logic, what should be displayed when this script is executed?

Answer...

  • None of the above
  • The XML of each 'title' node
  • The XML of each 'item' node
  • "Title" for every title node in the document
  • The contents of every 'title' node which exists under an 'item' node

Question 11

Which of the following is the best way to split a string on the "-=-" pattern?

Answer...

  • They all are equally proper methods
  • str_split($string, strpos($string, "-=-"))
  • preg_split("-=-", $string);
  • explode("-=-" $string);

Question 12

SimpleXML objects can be created from what types of data sources?

Answers: (choose 3)

  • A String
  • An array
  • A DomDocument object
  • A URI
  • A Database resource

Question 13

Which of the following are valid PHP variables?

Answers: (choose 4)

  • @$foo
  • &$variable
  • ${0x0}
  • $variable
  • $0x0

Question 14

When implementing a permissions system for your Web site, what should always be done with regards to the session?

Answer...

  • None of the above
  • You should not implement permission systems using sessions
  • Sessions should be cleared of all data and re-populated
  • The session key should be regenerated
  • The session should be destroyed

Question 15

SQL Injections can be best prevented using which of the following database technologies?

Answers: (choose 1)

  • All of the above
  • Prepared Statements
  • Persistent Connections
  • Unbuffered Queries
  • Query escaping

Question 16

When attempting to prevent a cross-site scripting attack, which of the following is most important?

Answer...

  • Not writing Javascript on the fly using PHP
  • Filtering Output used in form data
  • Filtering Output used in database transactions
  • Writing careful Javascript
  • Filtering all input

Question 17

What three special methods can be used to perform special logic in the event a particular accessed method or member variable is not found?

Answers: (choose 3)

  • __get($variable)
  • __call($method, $params)
  • __get($method)
  • __set($variable, $value)
  • __call($method)

Question 18

When running PHP in a shared host environment, what is the major security concern when it comes to session data?

Answer...

  • Sessions on shared hosts are easily hijacked by outside malicious users
  • All of the above
  • You cannot use a custom data store in shared hosts
  • Session data stored in the file system can be read by other scripts on the same shared host
  • Users outside the shared host can access any site which created a session for them

Question 19

A fingerprint of a string can be determined using which of the following?

Answer...

  • md5()
  • hash()
  • fingerprint()
  • None of the above

Question 20

When embedding PHP into XML documents, what must you ensure is true in order for things to function properly?

Answer...

  • Disabling of the short_tags PHP.ini directive
  • Enabling the asp_tags PHP.ini directive
  • That you have XPath support enabled in PHP 5
  • That your XML documents are well-formed
  • None of the above, PHP can be embedded in XML in all cases.

Question 21

What is the output of the following code?

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

Answer...

  • 312211
  • 3312212
  • 11221221
  • 221131
  • 3211122

Question 22

When working with a database, which of the following can be used to mitigate the possibility of exposing your database credientials to a malicious user?

Answers: (choose 3)

  • Moving all database credentials into a single file
  • Moving all database credentials outside of the document root
  • Restricting access to files not designed to be executed independently
  • Setting creditial information as system environment variables
  • Using PHP constants instead of variables to store credentials

Question 23

Consider the following code:

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)
}

/* .... */

What potential security hole would this code snippet produce?

Answer...

  • Cross-Site Scripting Attack
  • There is no security hole in this code
  • Code Injection
  • SQL Injection
  • Cross-Site Request Forgery

Question 24

Which statement will return the third parameter passed to a function?

Answer...

  • $argv[3];
  • $argv[2];
  • func_get_args(3);
  • func_get_arg(2);
  • func_get_arg(3);

Question 25

When is it important to validate data coming from an HTML form?

Answer...

  • Only when the fields are required
  • Only when accepting file uploads
  • Everywhere, except cookies
  • Only when accepting forms using an input type of text or a <textarea> field
  • None of the above

Question 26

Which of the following extensions are no longer part of PHP 5 and have been moved to PECL?

Answers: (choose 2)

  • tidy
  • mysql
  • w32api
  • curl
  • dio

Question 27

The following is a common XML structure used in service oriented architectures, what does it represent?

<?xml version="1.0"?>
<methodCall>
 <methodName>myMethod</methodName>
 <params>
  <param>
   <value><string>HI!</string></value>
  </param>
 </params>
</methodCall>

Answer...

  • None of the above
  • A fragment of a complete SOAP request
  • XML-RPC
  • REST
  • SOAP

Question 28

Which of the following functions could be used to break a string into an array?

Answers: (choose 3)

  • array_split()
  • split()
  • string_split()
  • preg_match_all()
  • explode()

Question 29

Which PCRE regular expression will match the string PhP5-rocks?

Answer...

  • /^[hp1-5]*\-.*/i
  • /[hp1-5]*\-.?/
  • /[hp][1-5]*\-.*/
  • /[PhP]{3}[1-5]{2,3}\-.*$/
  • /[a-z1-5\-]*/
« «« Seite 1 von 2 »» »
Danke! :-)