3 Months Free Update
3 Months Free Update
3 Months Free Update
What is the output of the following code?
printf('%4$d %2$s sit on 2 trees and eat %3$3.2f %1$s', "bananas",
"monkeys", 9, 99);
Given the default PHP configuration, how can all of the parameters provided via GET be accessed in a form of a string?
Which of the following functions can help prevent session fixation vulnerabilities?
Given the following two functions, what statement is correct?
function dynamicNew($name) {
return new $name;
}
function reflectionNew($name) {
$r = new ReflectionClass($name);
return $r->newInstanceArgs();
}
What is the purpose of the 4th argument to the file_get_contents() function?
When PHP is running on a command line, what super-global will contain the command line arguments specified?
What is the method used to execute XPath queries in the SimpleXML extension?
PHP's array functions such as array_values() and array_key_exists() can be used on an object if the object...
The XML document below has been parsed into $xml via SimpleXML. How can the value of
accessed?
Which of the following statements about database connections are commonly true? (Choose 2)
What will the $array array contain at the end of this script?
1
2 function modifyArray (&$array)
3 {
4 foreach ($array as &$value)
5 {
6 $value = $value + 1;
7 }
8
9 $value = $value + 2;
10 }
11
12 $array = array (1, 2, 3);
13 modifyArray($array);
14 ?>
What is the name of the method that can be used to provide read access to virtual properties in a class?
What XML component does the following XPath query try to match?
//foo[bar/@id=5]
What is the output of the following code:
str_replace(array("Apple","Orange"), array("Orange","Apple"), "Oranges are orange and Apples are green");
An HTML form contains this form element:
The user clicks on the image to submit the form. How can you now access the relative coordinates of the mouse click?
Which of the following statements is NOT true?
a) Class constants are public
b) Class constants are being inherited
c) Class constants can omit initialization (default to NULL)
d) Class constants can be initialized by consts
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?
Which of the following data types cannot be directly manipulated by the client?
Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42;
}
$z = new stdClass;
f($z);
var_dump($z);
What is the return value of the following code?
strpos("me myself and I", "m", 2)
What super-global should be used to access information about uploaded files via a POST request?
The following form is loaded in a browser and submitted, with the checkbox activated:
What is the content of $c after the following code has executed?
$a = 2;
$b = 3;
$c = ($a++ * ++$b);
What is the error in the following declaration of a static class method?
1
2 class car {
3 static $speeds = array(
4 'fast',
5 'slow',
6 'medium',
7 );
8
9 static function getSpeeds()
10 {
11 return $this->speeds;
12 }
13 }
14 ?>
How many elements does the $matches array contain after the following function call is performed?
preg_match('/^(\d{1,2}([a-z]+))(?:\s*)\S+ (?=200[0-9])/', '21st March
2006', $matches);
Identify the security vulnerability in the following example:
1
2 echo "Welcome, {$_POST['name']}.";
3 ?>
Given the following code, what will be the value of $a?
$a = array('a', 'b');
array_push($a, array(1, 2));
What is the output of the following script?
1
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 configuration directives increase the risk of remote code injection when enabled? (Choose 2)
Which of the following is correct? (Choose 2)
1) A class can extend more than one class.
2) A class can implement more than one class.
3) A class can extend more than one interface.
4) A class can implement more than one interface.
5) An interface can extend more than one interface.
6) An interface can implement more than one interface.
Which parts of the text are matched in the following regular expression?
1
2 $text = << 3 The big bang bonged under the bung. 4 EOT; 5 6 preg_match_all('@b.n?g@', $text, $matches); 7 ?>
Which of these protocols are NOT governed by the W3C in their latest versions? (Choose 2)
What method can be used to find a tag with the name "foo" via the DOM extension?
You are creating an application that repeatedly connects to a database to retrieve order data for invoices. All data comes from the same database. In order to preserve resources, you have to ensure that only one database connection should be used at any time. The code also has to open as few new database connections as possible. Which design pattern should you use for this scenario?
Which is the most efficient way to determine if a key is present in an array,assuming the array has no NULL values?
Which of the following techniques ensures that a value submitted in a form can only be yes or no?
Is the following code piece E_STRICT compliant?
final class Testing {
var $test = 0;
public function tester() {
return "Tested!";
}}
How can the constant defined below be accessed from within PHP?
class myClass {
const FOO = 'BAR';
}
Is the following code piece E_STRICT compliant?
final class Testing {
private $test;
public function tester() {
return "Tested!";
}}
Which technique should be used to speed up joins without changing their results?
You need to escape special characters to use user input inside a regular expression. Which functions would you use? (Choose 2)