How many elements does the array $pieces contain after the following piece of code has been executed?
$pieces = explode( " / " , " /// " );
Which of the following functions can help prevent session fixation vulnerabilities?
Which of the following function signatures is correct if you want to have classes automatically loaded?
Which of the following parts must a XML document have in order to be well-formed?
What is the output of the following code:
str_replace(array( " Apple " , " Orange " ), array( " Orange " , " Apple " ), " Oranges are orange and Apples are green " );
Which of the following code snippets is correct? (Choose 2)
a)
interface Drawable {
abstract function draw();
}
b)
interface Point {
function getX();
function getY();
}
c)
interface Line extends Point {
function getX2();
function getY2();
}
d)
interface Circle implements Point {
function getRadius();
}
The following code piece should print " PHP is cool " , but unexpectedly, it just prints " cool " . How would you correct it?
echo str_replace( ' PHP is a pain. ' , ' a pain ' , ' cool ' );
Which technique should be used to speed up joins without changing their results?
What is the output of the following script?
1 < ?php
2 function ratio ($x1 = 10, $x2)
3 {
4 if (isset ($x2)) {
5 return $x2 / $x1;
6 }
7 }
8
9 echo ratio (0);
10 ? >
What can prevent PHP from being able to open a file on the hard drive (Choose 3)?
How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML object found inside $xml?
< ?xml version= ' 1.0 ' ? >
< foo >
< bar >
< baz id= " 1 " > One < /baz >
< baz id= " 2 " > Two < /baz >
< /bar >
< /foo >
The XML document below has been parsed into $xml via SimpleXML. How can the value of < foo > tag
accessed?
< ?xml version= ' 1.0 ' ? >
< document >
< bar >
< foo > Value < /foo >
< /bar >
< /document >
Given the following array:
$a = array(28, 15, 77, 43);
Which function will remove the value 28 from $a?
What is the output of the following code?
try {
class MyException extends Exception {};
try {
throw new MyException;
}
catch (Exception $e) {
echo " 1: " ;
throw $e;
}c
atch (MyException $e) {
echo " 2: " ;
throw $e;
}}
catch (Exception $e) {
echo get_class($e);
}
What happens if you try to access a property whose name is defined in a parent class as private, and is not declared in the current class?
You want to extract the pieces of a date string, which looks like this:
" 2005-11-02 " . Which of the following pieces of code will properly assign $year,
$month and $day with their respective values?
Given the default PHP configuration, how can all of the parameters provided via GET be accessed in a form of a string?
After running this sort, what will be the value of $b?
$a = array( ' _! ' , ' def ' , 0);
$b = sort($a);
What is the output of the following script?
1 < ?php
2 function fibonacci ( & $x1 = 0, & $x2 = 1)
3 {
4 $result = $x1 + $x2;
5 $x1 = $x2;
6 $x2 = $result;
7
8 return $result;
9 }
10
11 for ($i = 0; $i < 10; $i++) {
12 echo fibonacci() . ' , ' ;
13 }
14 ? >
How many elements does the array $matches from the following code contain?
1 < ?php
2 $str = " The cat sat on the roof of their house. " ;
3
4 $matches = preg_split( " /(the)/i " , $str, -1,
PREG_SPLIT_DELIM_CAPTURE);
5 ? >
What is the output of the following code?
1 < ?php
2 for ($i = 0; $i < 1.02; $i += 0.17) {
3 $a[$i] = $i;
4 }
5 echo count($a);
6 ? >
What is the output of the following code?
1 < ?php
2 function append($str)
3 {
4 $str = $str. ' append ' ;
5 }
6
7 function prepend( & $str)
8 {
9 $str = ' prepend ' .$str;
10 }
11
12 $string = ' zce ' ;
13 append(prepend($string));
14 echo $string;
15 ? >
What will be the value of $b after running the following code?
$a = array( ' c ' , ' b ' , ' a ' );
$b = (array)$a;
What is the output of the following script?
1 < ?php
2 function fibonacci ($x1, $x2)
3 {
4 return $x1 + $x2;
5 }
6
7 $x1 = 0;
8 $x2 = 1;
9
10 for ($i = 0; $i < 10; $i++) {
11 echo fibonacci($x1, $x2) . ' , ' ;
12 }
13 ? >
Which of the following can be registered as entry points with a SoapServer instance (choose 3)
What is the output of the following code?
echo 0x33, ' monkeys sit on ' , 011, ' trees. ' ;
Identify the security vulnerability in the following example:
1 < ?php
2 echo " Welcome, {$_POST[ ' name ' ]}. " ;
3 ? >
You are creating an application that generates invoices in a variety of formats, including PDF, ODS and HTML. Each of these formats is represented as a PHP class in your application. While some of the operations can be performed on all of the different formats (such as saving and loading), other operations may be specific to one or two of the formats (such as setting as read only). Which design pattern should you use for this application?
What is the output of the following code?
$first = " second " ;
$second = " first " ;
echo $$$first;
Would the following code catch a parse error?
try {
echo $label
} catch (Exception $e) {
echo $e- > getMessage();
}
When working with the MVC paradigma, the business logic should be implemented in which of the following components?
What DOMElement method should be used to check for availability of a non-namespaced attribute?
You want to run the following PHP 4 code with PHP 5. In the following example, which access modifier in PHP 5 is equivalent to " var " ?
class Test {
var $tester;
}
What function should be used to escape command line arguments that are passed to commands executed from PHP?
Type hinting in PHP allows the identification of the following variable types: (Choose 2)
Given the following code, what is correct?
function f(stdClass & $x = NULL) { $x = 42;
}
$z = new stdClass;
f($z);
var_dump($z);
How many times will the function counter() be executed in the following code?
function counter($start, & $stop)
{
if ($stop > $start)
{
return;
} counter($start--, ++$stop);
}
$start = 5;
$stop = 2;
counter($start, $stop);
Which of the following data types is implicitly passed by reference in PHP 5 while it is passed by value in PHP 4?