A script residing at <a href="http://example.com/phpcert/cookies.php">http://example.com/phpcert/cookies.php</a> contains the following code:
1 <?php
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?
Given the following code, what will be the value of $a?
$a = array('a', 'b');
array_push($a, array(1, 2));
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);
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
What function should be used to escape command line arguments that are passed to commands executed from PHP?
Identify the security vulnerability in the following example:
1 <?php
2 echo "Welcome, {$_POST['name']}.";
3 ?>
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;
}
Which methods can be used to overload object properties? (Choose 2)
What does the __FILE__ constant contain?
You want to present the following formatted number: "999.000.000,00". Which function call is correct?
What will be the result of the following operation?
array_combine(array("A","B","C"), array(1,2,3));
Transactions are used to:
What is the purpose of the 4th argument to the file_get_contents() function?
How can you determine if magic_quotes_gpc is enabled? (Choose 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);
When PHP is running on a command line, what super-global will contain the command line arguments specified?
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 ?>
Which of the following XML declarations is NOT valid?
What will the following code piece print?
echo strtr('Apples and bananas', 'ae', 'ea')
What will the following code print?
echo addslashes('I am a small "HTML" string, which is
\'invalid\'.');
What will be the output value of the following code?
$array = array(1,2,3);
while (list(,$v) = each($array));
var_dump(current($array));
What is the output of the following code?
$a = 1;
++$a;
$a*=$a;
echo $a--;
What is the output of the following code?
$a = 3;
switch ($a) {
case 1: echo 'one'; break;
case 2: echo 'two'; break;
default: echo 'four'; break;
case 3: echo 'three'; break;
}
Which of the following superglobals does not contain data from the client?
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 can prevent PHP from being able to open a file on the hard drive (Choose 3)?
How can the constant defined below be accessed from within PHP?
class myClass {
const FOO = 'BAR';
}
How can XML parsing errors be suppressed in the SimpleXML extension?
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 <?php
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 type of class definition can be used to define multiple inheritance?
Which sentence describes the following regular expression match?
preg_match('/^\d*(?:\.[0-9]+)?$/', $test);