Some ZCE Mock Exam Questions

Tags:
Seite:
1
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)

Question 2

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

Answers:

Question 3

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

Answers:

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)

Question 5

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

Answers: (choose 2)

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…

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...

Question 8

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

Answer...

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 <<a href="http://example.org/">http://www.example.org/</a>.>
      <br/>
    </p>
  </body>
</html>

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

Answer...

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...

Question 11

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

Answer...

Question 12

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

Answers: (choose 3)

Question 13

Which of the following are valid PHP variables?

Answers: (choose 4)

Question 14

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

Answer...

Question 15

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

Answers: (choose 1)

Question 16

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

Answer...

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)

Question 18

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

Answer...

Question 19

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

Answer...

Question 20

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

Answer...

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...

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)

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...

Question 24

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

Answer...

Question 25

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

Answer...

Question 26

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

Answers: (choose 2)

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...

Question 28

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

Answers: (choose 3)

Question 29

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

Answer...

Seite:
1
2

Ähnliche Artikel

Kommentare