The constructs for(), foreach(), and each() can all be used to iterate an object if the object
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);
}
The following form is loaded in a recent browser and submitted, with the second list element selected:
In the server-side PHP code to deal with the form data, what is the value of $_POST['list']?
Which of the following statements about PHP is true? (Choose 3)
a) A final class can be derived.
b) A final class may be instantiated.
c) A class with a final function may be derived.
d) Static functions can be final.
e) Properties can be final.
Would the following code catch a parse error?
try {
echo $label
} catch (Exception $e) {
echo $e->getMessage();
}
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;
}
Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42;
}
$z = new stdClass;
f($z);
var_dump($z);
Which constant must be passed as the second argument to htmlentities() to convert single quotes (') to HTML entities?
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?
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 ?>
Which of the following functions can help prevent session fixation vulnerabilities?
After running this sort, what will be the value of $b?
$a = array('_!', 'def', 0);
$b = sort($a);
When PHP is running on a command line, what super-global will contain the command line arguments specified?
An HTML form contains this form element:
When this form is submitted, the following PHP code gets executed:
1
2 move_uploaded_file(
3 $_FILES['myFile']['tmp_name'],
4 'uploads/' . $_FILES['myFile']['name']);
5 ?>
Which of the following actions must be taken before this code may go into production?
(Choose 2)
Which one of the following technologies was not built into PHP before version 5?
Assume that you are using PHP s session management without cookies and want to make sure that session information does not get lost when redirecting the client to another URL. Which of the following functions do you need to achieve that? (Choose 3)
You analyze the code of a collegue and see, it uses the function strcasecmp. You try it out to see what it does and use the following function call:
strcasecmp('hello my dear!', 'Hello my DEAR!');
The function call returns "0". What does that mean?