Given the following array:
$a = array(28, 15, 77, 43);
Which function will remove the value 28 from $a?
In the following code, which class can be instantiated?
1
2 abstract class Graphics {
3 abstract function draw($im, $col);
4 }
5
6 abstract class Point1 extends Graphics {
7 public $x, $y;
8 function __construct($x, $y) {
9 $this->x = $x;
10 $this->y = $y;
11 }
12 function draw($im, $col) {
13 ImageSetPixel($im, $this->x, $this->y, $col);
14 }
15 }
16
17 class Point2 extends Point1 { }
18
19 abstract class Point3 extends Point2 { }
20 ?>
What function should be used to escape command line arguments that are passed to commands executed from PHP?
You need to escape special characters to use user input inside a regular expression. Which functions would you use? (Choose 2)
What is the name of the key pointing to the domain name in the array returned by parse_url()?
An HTML form contains this form element
When this form is submitted, the following PHP code gets executed:
move_uploaded_file(
$_FILES['myFile']['tmp_name'],
'uploads/' . $_FILES['myFile']['name']);
Which of the following actions must be taken before this code may go into production?
(Choose 2)
What super-global should be used to access information about uploaded files via a POST request?
What function can be used to retrieve an array of current options for a stream context?
Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42;
}
$z = new stdClass;
f($z);
var_dump($z);
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();
}
Is the following code piece E_STRICT compliant?
final class Testing {
private $test;
public function tester() {
return "Tested!";
}}
Which of the listed changes would you make to the following PHP 4 code in order to make it most compliant with PHP 5? (Choose 2)
class Car {
var $model;
function Car($model) {
$this->model = $model;
} function toString() {
return "I drive a $this->model.";
}}
$c = new Car('Dodge');
echo $c->toString();
?>
In a shared hosting environment, session data can be read by PHP scripts written by any user. How can you prevent this?
Which of the following configuration directives increase the risk of remote code injection when enabled? (Choose 2)
Which of the following parts must a XML document have in order to be well-formed?
Identify the security vulnerability in the following example:
1
2 echo "Welcome, {$_POST['name']}.";
3 ?>
What function can reverse the order of values in an array without the loss of key information?
What is the return value of the following code?
strpos("me myself and I", "m", 2)
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);
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 ?>
A script residing at http://example.com/phpcert/cookies.php contains the following code:
1
2 setcookie('name1', 'value1', time() + 60*60*24, '/');
3 setcookie('name1', 'value2');
4 ?>
The web browser is configured to accept all cookies. How many cookies will be set by this script?
You want to access the 3rd character of a string, contained in the variable $test. Which of the following possibilities work?(Choose 2)
Given the default PHP configuration, how can all of the parameters provided via GET be accessed in a form of a string?
What will the following code piece print?
echo strtr('Apples and bananas', 'ae', 'ea')
You analyze the code of a colleague and see a call to the function quotemeta(). You give the string "Holy $%&[. What's going on?" as a parameter to it. What will it output?