Which constant must be passed as the second argument to htmlentities() to convert single quotes (') to HTML entities?
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?
What is the output of the following script?
1
2 class a
3 {
4 public $val;
5 }
6
7 function renderVal (a $a)
8 {
9 if ($a) {
10 echo $a->val;
11 }
12 }
13
14 renderVal (null);
15 ?>
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 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();
?>
One common security risk is exposing error messages directly in the browser. Which PHP configuration directive can be disabled to prevent this?
You work for a shared hosting provider, and your supervisor asks you to disable user scripts to dynamically load PHP extensions using the dl() function. How can you do this? (Choose 2)
$_SERVER consists of data provided by the web server and is therefore trustworthy.
How to read a single line, no matter how long from an file opened in the example below?
$fp = fopen("my_file.txt", "w");
What is the output of the following script?
1
2 function ratio ($x1 = 10, $x2)
3 {
4 if (isset ($x2)) {
5 return $x2 / $x1;
6 }
7 }
8
9 echo ratio (0);
10 ?>
What is the output of the following script?
1
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 ?>
Identify the security vulnerability in the following example:
1
2 mail('feedback@example.org',
3 'Feddback',
4 'Here is my feedback.',
5 "From: {$_COOKIE['email']}");
6 ?>
What is the output of the following code:
str_replace(array("Apple","Orange"), array("Orange","Apple"), "Oranges are orange and Apples are green");
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?
Which of the following code snippets writes the content of the file "source.txt" to "target.txt"? (Choose 3)
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();
}