You'll find my (!) answers on the next page. Have fun!
What are the primary benefits of object oriented programming?
Answers: (choose 3)
The _____ keyword is used to block any overriding of a class/method by a subclass.
Answers:
Event-based XML parsing is an example of which parsing model?
Answers:
Which functions would be needed to translate the following string:
I love PHP 5
to the following?
5 PHP EVOL I
Answers: (choose 2)
Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?
Answers: (choose 2)
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...
Given the string:
$var = "john@php.net";
Which of the following will extract the TLD (top level domain) of ".net" from the string?
Answer...
The ____ construct is particularly useful to assign your own variable names to values within an array.
Answer...
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...
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...
Which of the following is the best way to split a string on the "-=-" pattern?
Answer...
SimpleXML objects can be created from what types of data sources?
Answers: (choose 3)
Which of the following are valid PHP variables?
Answers: (choose 4)
When implementing a permissions system for your Web site, what should always be done with regards to the session?
Answer...
SQL Injections can be best prevented using which of the following database technologies?
Answers: (choose 1)
When attempting to prevent a cross-site scripting attack, which of the following is most important?
Answer...
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)
When running PHP in a shared host environment, what is the major security concern when it comes to session data?
Answer...
A fingerprint of a string can be determined using which of the following?
Answer...
When embedding PHP into XML documents, what must you ensure is true in order for things to function properly?
Answer...
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...
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)
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...
Which statement will return the third parameter passed to a function?
Answer...
When is it important to validate data coming from an HTML form?
Answer...
Which of the following extensions are no longer part of PHP 5 and have been moved to PECL?
Answers: (choose 2)
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...
Which of the following functions could be used to break a string into an array?
Answers: (choose 3)
Which PCRE regular expression will match the string PhP5-rocks?
Answer...