1.What is the default value for the "max_execution_time" setting when running PHP as a CLI SAPI ?
Whatever is set as the value for "max_execution_time" in php.ini
0 (Zero) which stands for infinite
There is no "max_execution_time" setting if running PHP as a CLI SAPI
2.Considering the code below ...
<?php class AppException extends Exception { function __toString() { return "Your code has just thrown an exception: {$this->message}\n"; } } class Students { public $first_name; public $last_name; public function __construct($first_name, $last_name) { if(empty($first_name)) { throw new AppException('First Name is required', 1); } if(empty($last_name)) { throw new AppException('Last Name is required', 2); } } } try { new Students('', ''); } catch (Exception $e) { echo $e; }
... which of these statements are correct ?
The catch (Exception $e) statement is wrong because it accepts an instance of the Exception class as the parameter. It should use an instance of the AppException class instead.
catch (Exception $e)
The __toString() method can't be overwritten in a child class because the methods in the Exception class are all final but for the constructor
__toString()
Exception
The magic __toString() method will be invoked automatically when the code enters the catch() statement and the custom exception message will be printed
catch()
3.What is the output of the code below ?
<?php $a = array(); $a[0] = 1; unset($a[0]); echo ($a != null) ? 'True' : 'False';
True
False
Parse Error
4.How do you access standard I/O and error streams ?
Use stdin(), stdout() and stderr() functions
PHP::STDIN, PHP::STDOUT and PHP::STDERR class constants
Use PHP::stdin(), PHP::stdout() and PHP::stderr() class functions
STDIN, STDOUT and STDERR constants
5.Which of the following functions could be used to break a string into an array?
Which of the following functions could be used to break a string into an array?
array_split()
split()
string_split()
preg_match_all()
explode()
6.What is the output of the following code block? $array = array(1 => 0, 2, 3, 4); array_splice($array, 3, count($array), array_merge(array('x'), array_slice($array, 3))); var_dump($array);
What is the output of the following code block? $array = array(1 => 0, 2, 3, 4); array_splice($array, 3, count($array), array_merge(array('x'), array_slice($array, 3))); var_dump($array);
1 => 1, 2 => 2, 3 => x, 4 => 4
0 => 1, 2 => 2, 3 => 3, 4 => 4, x => 3
0 => 0, 1 => 2, 2 => 3, 3 => x, 4 => 4
0 => x, 1 => 0, 2 => 1, 3 => 2, 4 => 3
1 => 1, 3 => x, 2 => 2, 4 => 4
7.Which of the following functions are used with the internal array pointer to accomplish an action?
Which of the following functions are used with the internal array pointer to accomplish an action?
key
forward
prev
current
next
8.Given the following array: $array = array(1,1,2,3,4,4,5,6,6,6,6,3,2,2,2); The fastest way to determine the total number a particular value appears in the array is to use which function?
Given the following array: $array = array(1,1,2,3,4,4,5,6,6,6,6,3,2,2,2); The fastest way to determine the total number a particular value appears in the array is to use which function?
array_total_values
array_count_values
A foreach loop
count
a for loop
9.The ____ construct is particularly useful to assign your own variable names to values within an array.
The ____ construct is particularly useful to assign your own variable names to values within an array.
array_get_variables
each
import_variables
list
10.What is the output of the following PHP code? define("FOO", 10); $array = [10 => FOO,"FOO" => 20]; print $array[$array[FOO]] * $array["FOO"];
What is the output of the following PHP code? define("FOO", 10); $array = [10 => FOO,"FOO" => 20]; print $array[$array[FOO]] * $array["FOO"];
FOO
100
200
20
10
11.Transactions are used to...
Transactions are used to...
guarantee high performance
secure data consistency
secure access to the database
reduce the database server overhead
reduce code size in PHP
12.What would go in place of ?????? below to make this script execute without a fatal error? $a = 1; $b = 0; /* ?????? */ $c = $a / $b;
What would go in place of ?????? below to make this script execute without a fatal error? $a = 1; $b = 0; /* ?????? */ $c = $a / $b;
quit();
die();
stop();
__halt_compiler();
exit();
13.When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used?
When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used?
if($obj1->equals($obj2) && ($obj1 instanceof $obj2))
if($obj1->equals($obj2))
if($obj1 instanceof $obj2)
if($obj1 === $obj2)
14.In PHP 5 you can use the ______ operator to ensure that an object is of a particular type. You can also use _______ in the function declaration.
In PHP 5 you can use the ______ operator to ensure that an object is of a particular type. You can also use _______ in the function declaration.
instanceof, is_a
instanceof, type-hinting
type, instanceof
===, type-hinting
===, is_a
15.Type-hinting and the instanceof keyword can be used to check what types of things about variables?
Type-hinting and the instanceof keyword can be used to check what types of things about variables?
If a particular child class extends from it
If they are an instance of a particular interface
If they are an abstract class
If they have a particular parent class
If they are an instance of a particular class
16.The _______ method will be called automatically when an object is represented as a string.
The _______ method will be called automatically when an object is represented as a string.
getString()
__get()
__value()
__getString()
17.Which php.ini directive should be disabled to prevent the execution of a remote PHP script via an include or require construct?
Which php.ini directive should be disabled to prevent the execution of a remote PHP script via an include or require construct?
You cannot disable remote PHP script execution
curl.enabled
allow_remote_url
allow_url_fopen
allow_require
18.Consider the following code: header("Location: {$_GET['url']}\"); Which of the following values of $_GET['url'] would cause session fixation?
Consider the following code: header("Location: {$_GET['url']}\"); Which of the following values of $_GET['url'] would cause session fixation?
Session Fixation is not possible with this code snippet
http://www.zend.com/?PHPSESSID=123
PHPSESSID%611243
Set-Cookie%3A+PHPSESSID%611234
http%3A%2F%2Fwww.zend.com%2F%0D%0ASet-Cookie%3A+PHPSESSID%611234
19.Which of the following are not valid ways to embed a variable into a string?
Which of the following are not valid ways to embed a variable into a string?
$a = "Value: $value->getValue()";
$a = "Value: {$value}";
$a = 'Value: $value';
$a = "Value: $value";
$a = "Value: {$value['val']}";
20.Given the two values below, which of the following possibilities will print 10 foos20 bars? $var1 = "10 foos"; $var2 = "20 bars"; print ???????;
Given the two values below, which of the following possibilities will print 10 foos20 bars? $var1 = "10 foos"; $var2 = "20 bars"; print ???????;
implode("", array($var1,$var2));
$var1 . $var2
$var1 + $var2
All of the above
None of the above
21.Which of the following is the best way to split a string on the "-=-" pattern?
Which of the following is the best way to split a string on the "-=-" pattern?
They all are equally proper methods
str_split($string, strpos($string, "-=-"))
preg_split("-=-", $string);
explode("-=-", $string);
22.Which string does the following PCRE regular expression match? $regex = "/^([a-z]{5})[1-5]+([a-z]+)/";
Which string does the following PCRE regular expression match? $regex = "/^([a-z]{5})[1-5]+([a-z]+)/";
Hello34262343goodbye'
frank12345abc
hello34212343goodbye
abcdefghi12345abc
23.Which PCRE regular expression will match the string PhP5-rocks
Which PCRE regular expression will match the string PhP5-rocks
/^[hp1-5]*\-.*/i
/[hp1-5]*\-.?/
/[hp][1-5]*\-.*/
/[PhP]{3}[1-5]{2,3}\-.*$/
/[a-z1-5\-]*/
24.If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?
If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?
strtok() using regular expressions
preg_* regular expression functions
parse_str() using regular expressions
strregex* regular expression functions
ereg* regular expression functions
25.If you would like to store your session in the database, you would do which of the following?
If you would like to store your session in the database, you would do which of the following?
It requires a custom PHP extension to change the session handler
Implement the session_set_save_handler() function
Create functions for each session handling step and use session_set_save_handler() to override PHP's internal settings
Configure the session.save_handler INI directive to your session class
26.When uploading a file using HTTP, which variable can be used to locate the file on PHP's local filesystem?
When uploading a file using HTTP, which variable can be used to locate the file on PHP's local filesystem?
$_FILES['fieldname']['tmp_name']
$_FILES['fieldname']
$_FILES['fieldname'][0]['filename']
$_FILES['fieldname']['filename']
27.Setting a cookie on the client in PHP 5 can be best accomplished by:
Setting a cookie on the client in PHP 5 can be best accomplished by:
Use the add_cookie() function
Use the setcookie() function
Use the the apache_send_header() function
Setting a variable in the $_COOKIE superglobal
28.One can ensure that headers can always be sent from a PHP script by doing what?
One can ensure that headers can always be sent from a PHP script by doing what?
Enable header buffering in PHP 5
Set the header.force INI directive to true
Enable output buffering in PHP 5
There is no way to ensure that headers can always be set, they must always be checked
29.Which of the following is not a valid fopen() access mode:
Which of the following is not a valid fopen() access mode:
b
x
a
w
r+
30.Which functions would be needed to translate the following string: I love PHP 5 to the following? 5 PHP EVOL I
Which functions would be needed to translate the following string: I love PHP 5 to the following? 5 PHP EVOL I
mirror()
strtoupper()
toupper()
str_reverse()
strrev()