200-710 6-0
200-710 6-0
Version 6.0
QUESTION NO: 2
What is the difference between the spaceship operator (<=>) and the strcmp() function?
Answer: D
QUESTION NO: 15
Which of these error types may be handled by a user defined error handler function? (Choose
two.)
A. E_ERROR
B. E_NOTICE
C. E_PARSE
D. E_WARNING
Answer: A,C
QUESTION NO: 25
A. string(0) “”
B. bool(false)
C. string(1) “!”
D. string(2) “k!”
Answer: C
QUESTION NO: 28
A. The total execution time for all 3 requests will be the maximum of the longest sleep() call
B. The requests may be processed out of order
C. The requests are guaranteed to be executed in order
D. Concurrent requests will be blocked until the session lock is released
Answer: A
QUESTION NO: 39
Answer: A
QUESTION NO: 43
What is the benefit of using persistent database connections in PHP? (Choose two.)
Answer: C,D
QUESTION NO: 44
Answer: B
QUESTION NO: 57
What function is best suited for extracting data from a formatted string into an array?
A. fgetcsv
B. sscanf
C. sprintf
D. strtok
Answer: C
QUESTION NO: 65
What exception type will catch the error raised by the expression 2 / 0?
A. LogicException
B. RangeException
C. DivisionByZeroError
D. ArithmeticError
Answer: C
QUESTION NO: 1
What is the output of the following code?
A. 123
B. 213
C. 142
D. 214
E: Syntax error
Answer: D
QUESTION NO: 2
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;
}
A. one
B. two
C. three
D. four
Answer: C
QUESTION NO: 3
What is "instanceof" an example of?
A. a boolean
B. an operator
C. a function
D. a language construct
E: a class magic
Answer: B
QUESTION NO: 4
Which of the following may be used in conjunction with CASE inside a SWITCH statement?
A. A scalar
B. An expression
C. A boolean
D. All of the above
Answer: D
QUESTION NO: 5
What is the output of the following code?
$a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';
A. abc
B. cd
C. 0d
Answer: B
QUESTION NO: 6
Which of the following are valid identifiers? (Choose 3)
A. function 4You() { }
B. function _4You() { }
C. function object() { }
D. $1 = "Hello";
E: $_1 = "Hello World";
Answer: B, C, E
QUESTION NO: 7
What super-global should be used to access information about uploaded files via a POST
request?
A. $_SERVER
B. $_ENV
C. $_POST
D. $_FILES
E: $_GET
Answer: D
QUESTION NO: 8
What is the difference between "print" and "echo"?
A. There is no difference.
B. Print has a return value, echo does not
C. Echo has a return value, print does not
D. Print buffers the output, while echo does not
E: None of the above
Answer: B
QUESTION NO: 9
What is the output of the following code?
A. 1
B. 3
C. 5
D. 20
E: 7
Answer: C
QUESTION NO: 10
What is the result of the following bitwise operation in PHP?
1^2
A. 1
B. 3
C. 2
D. 4
E: -1
Answer: B
QUESTION NO: 11
What is the output of the following code?
A. 220.2231
B. 22.2231
C. 22.2,231
D. 56.2
Answer: B
QUESTION NO: 12
What is the output of the following code?
$first = "second";
$second = "first";
echo $$$first;
A. "first"
B. "second"
C. an empty string
D. an error
Answer: B
QUESTION NO: 13
Your supervisor wants you to disallow PHP scripts to open remote HTTP and FTP resources
using PHP's file functions. Which php.ini setting should you change accordingly?
QUESTION NO: 16
Which of the following will set a 10 seconds read timeout for a stream?
A. ini_set("default_socket_timeout", 10);
B. stream_read_timeout($stream, 10);
C. Specify the timeout as the 5th parameter to the fsockopen() function used to open a stream
D. stream_set_timeout($stream, 10);
E: None of the above
Answer: D
QUESTION NO: 17
What function allows resizing of PHP's file write buffer?
A. ob_start()
B. set_write_buffer()
C. stream_set_write_buffer()
D. Change the output_buffering INI setting via ini_set() function
Answer: C
QUESTION NO: 18
What does the __FILE__ constant contain?
Answer: B
QUESTION NO: 19
What can prevent PHP from being able to open a file on the hard drive (Choose 2)?
Answer: A, B
QUESTION NO: 20
What purpose do namespaces fulfill?
A. Encapsulation
B. Alternative to classes
C. Improved performance
D. All of the above
Answer: A
QUESTION NO: 21
When would you use classes and when would you use namespaces?
A. Use classes to encapsulate code and represent objects, and namespaces to avoid symbol name
collisions
B. Use classes for performance-sensitive code, and namespaces when readability matters more
C. Use namespaces for performance-sensitive code, and classes when readability matters more
D. Always use them; namespaces are always superior to classes
Answer: A
QUESTION NO: 22
Which of these elements can be encapsulated by namespaces and made accessible from the
outside?
A. Only classes
B. Classes, functions and constants
C. Classes, functions, constants and variables
Answer: B
QUESTION NO: 23
You'd like to use the class MyDBConnection that's defined in the
MyGreatFramework\MyGreatDatabaseAbstractionLayer namespace, but you want to minimize
*as much as possible* the length of the class name you have to type. What would you do?
Answer: C
QUESTION NO: 24
How should you track errors on your production website?
A. Enabling display_errors
B. Enabling log_errors
C. Having a site-wide exception handler
D. Setting error_reporting to E_ALL & ~E_NOTICE
Answer: B
QUESTION NO: 25
What would be the output of the following code?
namespace MyFramework\DB;
class MyClass {
static function myName() {
return __METHOD__;
}
}
print MyClass::myName();
A. MyFramework\DB\myName
B. MyFramework\DB\MyClass\myName
C. MyFramework\DB\MyClass::myName
D. MyClass::myName
Answer: C
QUESTION NO: 26
Which of the following methods are available to limit the amount of resources available to PHP
through php.ini? (Choose 2)
Answer: A, C
QUESTION NO: 27
Consider the following two files. When you run test.php, what would the output look like?
test.php:
include "MyString.php";
print ",";
print strlen("Hello world!");
MyString.php:
namespace MyFramework\String;
function strlen($str)
{
return \strlen($str)*2; // return double the string length
}
print strlen("Hello world!")
A. 12,12
B. 12,24
C. 24,12
D. 24,24
E: PHP Fatal error: Cannot redeclare strlen()
Answer: C
QUESTION NO: 28
Which line of code can be used to replace the INSERT comment in order to output "hello"?
class C {
public $ello = 'ello';
public $c;
public $m;
function __construct($y) {
$this->c = static function($f) {
// INSERT LINE OF CODE HERE
};
$this->m = function() {
return "h";
};
}
}
$x = new C("h");
$f = $x->c;
echo $f($x->m);
Answer: B
QUESTION NO: 29
What is the output of the following code?
function z($x) {
return function ($y) use ($x) {
return str_repeat($y, $x);
};
}
$a = z(2);
$b = z(3);
echo $a(3) . $b(2);
A. 22333
B. 33222
C. 33322
D. 222333
Answer: B
QUESTION NO: 30
What is the output of the following code?
echo gettype($f);
A. hello
B. string
C. object
D. function
Answer: C
QUESTION NO: 31
What is the output of the following code?
class C {
public $x = 1;
function __construct() { ++$this->x; }
function __invoke() { return ++$this->x; }
function __toString() { return (string) --$this->x; }
}
A. 0
B. 1
C. 2
D. 3
Answer: D
QUESTION NO: 32
Consider the following code. Which keyword should be used in the line marked with
"KEYWORD" instead of "self" to make this code work as intended?
$item = Item::create();
$item->action(); // outputs "Item"
Answer: static
QUESTION NO: 33
Which SPL class implements fixed-size storage?
Answer: SplFixedArray
QUESTION NO: 34
In order to create an object storage where each object would be stored only once, you may use
which of the following? (Choose 2)
A. SplFixedArray
B. SplObjectStorage
C. SplString
D. spl_object_hash
E: spl_same_object
Answer: B, D
QUESTION NO: 35
What is the output of the following code?
class Base {
protected static function whoami() {
echo "Base ";
}
public static function whoareyou() {
static::whoami();
}
}
class B extends A {
public static function whoami() {
echo "B ";
}
}
B::test();
A. B B B B B
B. Base A Base A B
C. Base B B A B
D. Base B A A B
Answer: C
QUESTION NO: 36
Late static binding is used in PHP to:
QUESTION NO: 37
What is the output of the following code?
class Test {
public function __call($name, $args)
{
call_user_func_array(array('static', "test$name"), $args);
}
public function testS($l) {
echo "$l,";
}
}
A. A,
B. A,A,
C. A,A,A,
D. PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback
Answer: B
QUESTION NO: 38
Which of the following tasks can be achieved by using magic methods? (Choose 3)
Answer: A, D, F
QUESTION NO: 39
How should class MyObject be defined for the following code to work properly? Assume $array
is an array and MyObject is a user-defined class.
Answer: D
QUESTION NO: 40
Consider the following code. What change must be made to the class for the code to work as
written?
class Magic {
protected $v = array("a" => 1, "b" => 2, "c" => 3);
public function __get($v) {
return $this->v[$v];
}
}
$m = new Magic();
$m->d[] = 4;
echo $m->d[0];
QUESTION NO: 41
SimpleXML provides the ability to iterate over items in an XML document, as well as access
items within it as if they were object properties. When creating your own classes to access data,
implementing which of the following would NOT achieve this goal?
A. __toString
B. Iterator
C. __get/__set
D. ArrayAccess
Answer: A
QUESTION NO: 42
Which of the following is used to find all PHP files under a certain directory?
A. PHPIterator
B. RecursiveTreeIterator
C. RecursiveDirectoryIterator
D. SplTempFileObject
Answer: C
QUESTION NO: 43
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name']
have really been uploaded via HTTP?
QUESTION NO: 44
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name']
have really been uploaded via HTTP, and also save the contents into another folder?
Answer: tmp_name
QUESTION NO: 46
What is the name of the key in $_FILES['name'] that contains the number of bytes of the
uploaded file?
Answer: size
QUESTION NO: 47
What information can be used to reliably determine the type of an uploaded file?
A. MIME type
B. File name extension
C. Contents of the file
Answer: C
QUESTION NO: 48
Which MIME type is always sent by a client if a JPEG file is uploaded via HTTP?
A. image/jpeg
B. image/jpg
C. image/pjpeg
D. Depends on the client system
Answer: D
QUESTION NO: 49
Your application uses PHP to accept and process file uploads. It fails to upload a file that is 5 MB
in size, although upload_max_filesize is set to "10M". Which of the following configurations
could be responsible for this outcome? (Choose 2)
A. The PHP configuration option post_max_size is set to a value that is too small
B. The web server is using an incorrect encoding as part of the HTTP response sent to the client
C. The browser uses an incorrect encoding as part of the HTTP request sent to the server
D. The hidden form field MAX_FILE_SIZE was set to a value that is too small
E: PHP cannot process file uploads larger than 4 MB
Answer: A, D
QUESTION NO: 50
Consider the following table data and PHP code. What is the outcome?
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$stmt->bindColumn(3, $result);
$row = $stmt->fetch(PDO::FETCH_BOUND);
A. The database will return no rows.
B. The value of $row will be an array.
C. The value of $result will be empty.
D. The value of $result will be '[email protected]'.
Answer: D
QUESTION NO: 51
Consider the following table data and PHP code. What is the outcome?
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
$cmd = "INSERT INTO users (id, name, email) VALUES (:id, :name, :email)";
$stmt = $pdo->prepare($cmd);
$stmt->bindValue('id', 1);
$stmt->bindValue('name', 'anna');
$stmt->bindValue('email', '[email protected]');
$stmt->execute();
echo "Success!";
} catch (PDOException $e) {
echo "Failure!";
throw $e;
}
A. The INSERT will succeed and the user will see the "Success!" message.
B. The INSERT will fail because of a primary key violation, and the user will see the "Success!"
message.
C. The INSERT will fail because of a primary key violation, and the user will see a PDO
warning message.
D. The INSERT will fail because of a primary key violation, and the user will see the "Failure!"
message.
Answer: B
QUESTION NO: 52
Consider the following table data and PHP code. What is a possible outcome?
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
$result = $stmt->fetchAll(PDO::FETCH_BOTH);
$row = $result[0];
A. The value of $row is `array(0 => 'anna', 1 => '[email protected]')`.
B. The value of $row is `array('name' => 'anna', 'email' => '[email protected]')`.
C. The value of $row is `array(0 => 'anna', 'name' => 'anna', 1 => '[email protected]', 'email'
=> '[email protected]')`.
D. The value of $result is `array('anna' => '[email protected]')`.
Answer: C
QUESTION NO: 53
Consider the following table data and PHP code, and assume that the database supports
transactions. What is the outcome?
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);
try {
$pdo->exec("INSERT INTO users (id, name, email) VALUES (6, 'bill',
'[email protected]')");
$pdo->begin();
$pdo->exec("INSERT INTO users (id, name, email) VALUES (7, 'john',
'[email protected]')");
throw new Exception();
} catch (Exception $e) {
$pdo->rollBack();
}
A. The user 'bill' will be inserted, but the user 'john' will not be.
B. Both user 'bill' and user 'john' will be inserted.
C. Neither user 'bill' nor user 'john' will be inserted.
D. The user 'bill' will not be inserted, but the user 'john' will be.
Answer: A
QUESTION NO: 54
Given a PHP value, which sample shows how to convert the value to JSON?
A. $string = json_encode($value);
B. $string = Json::encode($value);
C. $json = new Json($value); $string = $json->__toString();
D. $value = (object) $value; $string = $value->__toJson();
Answer: A
QUESTION NO: 55
Given a JSON-encoded string, which code sample correctly indicates how to decode the string to
native PHP values?
Answer: C
QUESTION NO: 56
Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's
ext/json capabilities?
A. 'Hello, world!'
B. function(){ alert("Hello, world!"); }
C. array('Hello, world!')
D. array('message' => 'Hello, world!')
Answer: B
QUESTION NO: 57
Which of the following will NOT instantiate a DateTime object with the current timestamp?
Answer: D
QUESTION NO: 58
Given a DateTime object that is set to the first second of the year 2014, which of the following
samples will correctly return a date in the format '2014-01-01 00:00:01'?
A. $datetime->format('%Y-%m-%d %h:%i:%s')
B. $datetime->format('%Y-%m-%d %h:%i:%s', array('year', 'month', 'day', 'hour', 'minute',
'second'))
C. $datetime->format('Y-m-d H:i:s')
D. $date = date('Y-m-d H:i:s', $datetime);
Answer: C
QUESTION NO: 59
Given the following DateTime objects, what can you use to compare the two dates and indicate
that $date2 is the later of the two dates?
QUESTION NO: 60
Given the following DateTime object, which sample will NOT alter the date to the value '2014-
02-15'?
A. $date->sub(new DateInterval('P1M'));
B. $date->setDate(2014, 2, 15);
C. $date->modify('-1 month');
D. $date->diff(new DateInterval('-P1M'));
Answer: D
QUESTION NO: 61
Which interfaces could class C implement in order to allow each statement in the following code
to work? (Choose 2)
A. Iterator
B. ArrayAccess
C. IteratorAggregate
D. ArrayObject
Answer: A, C
QUESTION NO: 62
What is the output of the following code?
A. true
B. false
Answer: B
QUESTION NO: 63
What is the output of the following code?
class Bar {
private $a = 'b';
public $c = 'd';
}
$x = (array) new Bar();
A. false-false
B. false-true
C. true-false
D. true-true
Answer: B
QUESTION NO: 64
What is the output of the following code?
$a = array('a', 'b'=>'c');
echo property_exists((object) $a, 'a')?'true':'false';
echo '-';
echo property_exists((object) $a, 'b')?'true':'false';
A. false-false
B. false-true
C. true-false
D. true-true
Answer: B
QUESTION NO: 65
Assuming UTF-8 encoding, what is the value of $count?
A. 0
B. 4
C. 5
D. 7
Answer: C
QUESTION NO: 66
What is the output of this code?
$world = 'world';
echo <<<'TEXT'
hello $world
TEXT;
A. hello world
B. hello $world
C. PHP Parser error
Answer: C
QUESTION NO: 67
Given a php.ini setting of
default_charset = utf-8
echo '✂✔✝';
Answer: A
QUESTION NO: 68
What will the following code print out?
Answer: A
QUESTION NO: 69
What is the pattern modifier for handling UTF-8 encoded preg_* functionality?
A. e
B. u
C. PHP does not support UTF-8 encoded strings
D. A pattern modifier is not needed
Answer: B
QUESTION NO: 70
What is the output of the following code?
$text1 = <<<'TEXT'
$text
TEXT;
$text2 = <<<TEXT
$text1
TEXT;
echo "$text2";
A. This is text
B. $text
C. $text1
D. $text2
Answer: B
QUESTION NO: 71
Your public web application needs to provide access to binary files for registered users only.
How would you achieve this?
Answer: C
QUESTION NO: 72
What content-type is required when sending an HTTP POST using JavaScript to ensure that PHP
can access the data?
A. application/x-www-form-urlencoded
B. http/post
C. text/html
D. object/multipart-formdata
Answer: A
QUESTION NO: 73
From your PHP application, how can you send the same header twice, but with different values?
Answer: A
QUESTION NO: 74
Which class of HTTP status codes is used for server error conditions?
A. 2XX
B. 3XX
C. 4XX
D. 5XX
Answer: D
QUESTION NO: 75
Which class of HTTP status codes is used for redirections?
A. 2XX
B. 3XX
C. 4XX
D. 5XX
Answer: B
QUESTION NO: 76
Which of the following can NOT be used to send a cookie from within a PHP application?
A. header()
B. $_COOKIE
C. setcookie()
D. setrawcookie()
Answer: B
QUESTION NO: 77
Under what condition may HTTP headers be set from PHP if there is content echoed prior to the
header function being used?
Answer: B
QUESTION NO: 78
Before the headers are sent, how can you remove a previously set header?
Answer: A
QUESTION NO: 79
How can you determine whether a PHP script has already sent cookies to the client?
A. Use $_COOKIE
B. Use the getcookie() function
C. Use the headers_sent() function
D. Use JavaScript to send a second HTTP request
Answer: C
QUESTION NO: 80
An HTML form has two submit buttons. After submitting the form, how can you determine with
PHP which button was clicked?
Answer: D
QUESTION NO: 81
What is the output of the following code?
function append($str)
{
$str = $str.'append';
}
function prepend(&$str)
{
$str = 'prepend'.$str;
}
$string = 'zce';
append(prepend($string));
echo $string;
A. zceappend
B. prependzceappend
C. prependzce
D. zce
Answer: C
QUESTION NO: 82
What is the output of the following code?
$val = 1;
increment ($val);
echo $val;
Answer: 1
QUESTION NO: 83
What is the output of the following code?
$val = 1;
increment ($val);
echo $val;
Answer: 1
QUESTION NO: 84
What is the output of the following code?
$_GET['m'] = 1;
echo $_GET['m'];
Answer: 1
QUESTION NO: 85
How many times will the function counter() be executed in the following code?
$start = 5;
$stop = 2;
counter($start, $stop);
A. 3
B. 4
C. 5
D. 6
Answer: C
QUESTION NO: 86
How do you allow the caller to submit a variable number of arguments to a function?
Answer: B
QUESTION NO: 87
What will the $array array contain at the end of this script?
$value = $value + 2;
}
A. 2, 3, 4
B. 2, 3, 6
C. 4, 5, 6
D. 1, 2, 3
Answer: B
QUESTION NO: 88
What is the output of the following code?
class a
{
public $val;
}
renderVal (null);
Answer: B
QUESTION NO: 89
What is the output of the following code?
return $result;
}
A. An error
B. 1,1,1,1,1,1,1,1,1,1,
C. 1,1,2,3,5,8,13,21,34,55,
D. Nothing
Answer: B
QUESTION NO: 90
What is the output of the following code?
A. 0
B. An integer overflow error
C. A warning, because $x1 is not set
D. A warning, because $x2 is not set
E: A floating-point overflow error
F: Nothing
Answer: D
QUESTION NO: 91
Which of the following is NOT a valid function declaration?
QUESTION NO: 92
What is the output of the following code?
$a = 1;
Answer: 22
QUESTION NO: 93
Which of the following is true about stream contexts? (Choose 2)
Answer: A, C
QUESTION NO: 94
Consider the following code. What can be said about the call to file_get_contents?
$getdata = "foo=bar";
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $getdata
)
);
$context = stream_context_create($opts);
Answer: B
QUESTION NO: 95
What function can be used to retrieve an array of current options for a stream context?
A. stream_context_get_params
B. stream_context_get_default
C. stream_context_get_options
D. The 'options' element of the stream_get_meta_data return value
Answer: C
QUESTION NO: 96
When retrieving data from URLs, what are valid ways to make sure all file_get_contents calls
send a certain user agent string? (Choose 2)
Answer: A, C
QUESTION NO: 97
What will an opcode cache ALWAYS automatically improve?
A. Running time of a loop in a PHP script
B. Efficiency of HTML markup generated by a PHP script
C. Execution speed of a PHP script
D. Memory footprint of a PHP script
E: None of the above
Answer: E
QUESTION NO: 98
What is cached by an opcode cache?
Answer: A
QUESTION NO: 99
Which php.ini setting is usually required to use an opcode cache?
A. extension
B. zend_extension
C. optimizer
D. dl
Answer: B
var_dump(boolval(-1));
A. bool(true)
B. bool(false)
Answer: A
QUESTION NO: 101
What is the output of the following code?
var_dump(boolval([]));
A. bool(true)
B. bool(false)
Answer: B
var_dump(boolval(new StdClass()));
A. bool(true)
B. bool(false)
Answer: A
Which operator needs to be used instead of ??? so that $result equals $value1 if $value1
evaluates to true, and equals $value2 otherwise? Just state the operator as it would be required in
the code.
Answer: ?:
Answer: B, E
trait MyTrait {
private $abc = 1;
public function increment() {
$this->abc++;
}
public function getValue() {
return $this->abc;
}
}
class MyClass {
use MyTrait;
public function incrementBy2() {
$this->increment();
$this->abc++;
}
}
$c = new MyClass;
$c->incrementBy2();
var_dump($c->getValue());
Answer: D
QUESTION NO: 106
Given the following code, how can we use both traits A and B in the same class? (select all that
apply)
trait A {
public function hello() {
return "hello";
}
public function world() {
return "world";
}
}
trait B {
public function hello() {
return "Hello";
}
public function person($name) {
return ":$name";
}
}
Answer: B
class A {
protected $x = array(); /* A */
$a = new A(); /* D */
array_push($a->getX(), "one");
array_push($a->getX(), "two");
echo count($a->getX());
Answer: C
A. 9
B. 6
C. 0
D. 3
Answer: B
QUESTION NO: 109
What is the output of the following code?
class Number {
private $v = 0;
public function __construct($v) { $this->v = $v; }
public function mul() {
return function ($x) { return $this->v * $x; };
}
}
Answer: 5
Answer: C
Answer: B, C
A. 4
B. 3
C. 2
D. false
E: Parse error
Answer: B
A. array_unique_values
B. array_distinct
C. array_count_values
D. array_intersect
E: array_values
Answer: C
A. The algorithm that is used for hashing passwords can change when PHP is upgraded.
B. The salt option should always be set to a longer value to account for future algorithm
requirements.
C. The string length of the returned hash can change over time.
D. The hash algorithm that's used will always be compatible with crypt() .
Answer: A, C
A. md5()
B. hash_pbkdf2()
C. password_hash()
D. crypt()
E. openssl_digest()
Answer: A, E
Answer: A
$age = $mysqli->real_escape_string($_GET['age']);
$name = $mysqli->real_escape_string($_GET['name']);
$query = "SELECT * FROM `table` WHERE name LIKE '$name' AND age = $age";
$results = $mysqli->query($query);
Answer: D
Answer: C
A. header_add()
B. header()
C. http_set_status()
D. http_response_code()
E: http_header_set()
Answer: B, D
A. Authorization-Required
B. WWW-Authenticate
C. HTTP-Authenticate
D. Authentication-Required
E: HTTP-Auth
Answer: B
A. Basic
B. Advanced
C. Strict
D. Digest
E: Realm
Answer: A, D
QUESTION NO: 123
Which of the following items in the $_SERVER superglobal are important for authenticating the
client when using HTTP Basic authentication? (Choose 2)
A. PHP_AUTH_TYPE
B. PHP_AUTH_PASSWORD
C. PHP_AUTH_DIGEST
D. PHP_AUTH_PW
E: PHP_AUTH_USER
Answer: D, E
A. session.upload_progress.file
B. session.upload_progress.key
C. session.upload_progress.prefix
D. session.upload_progress.freq
E: session.upload_progress.name
Answer: C, E
A. session_set_handler()
B. session_set_storage_handler()
C. session_register_handler()
D. session_set_save_handler()
Answer: D
QUESTION NO: 126
Which of these databases is NOT supported by a PDO driver?
Answer: D
Answer: B
class test {
public $value = 0;
function test() {
$this->value = 1;
}
function __construct() {
$this->value = 2;
}
}
$object = new test();
echo $object->value;
A. 2
B. 1
C. 0
D. 3
E: No Output, PHP will generate an error message.
Answer: A
A. set(), get()
B. __set(), __get()
C. __put(), __receive(), __exists()
D. set(), get(), isset()
E: __isset(), __unset()
Answer: B, E
class T
{
const A = 42 + 1;
}
echo T::A;
A. 42
B. 43
C. Parse error
Answer: C
Answer: C
define('PI', 3.14);
class T
{
const PI = PI;
}
class Math
{
const PI = T::PI;
}
echo Math::PI;
A. Parse error
B. 3.14
C. PI
D. T::PI
Answer: B
$z = new stdClass;
f($z);
var_dump($z);
Answer: E
Answer: A
Answer: B
Answer: A, B
Answer: E
Answer: C
QUESTION NO: 139
What is the name of the method that can be used to provide read access to virtual properties in a
class?
A. __call()
B. __get()
C. __set()
D. __wakeup()
E: __fetch()
Answer: B
Answer: D
A. autoload()
B. __autoload()
C. __catch()
D. load()
E: loadClass()
Answer: B
Answer: A
A. String
B. Integer
C. Array
D. Any class or interface type
E: All of the above
Answer: C, D
A. Graphics
B. Point1
C. Point2
D. Point3
E: None, the code is invalid
Answer: C
A. interface Drawable {
abstract function draw();
}
B. interface Point {
function getX();
function getY();
}
Answer: B, C
Answer: A, E
Answer: D, E
A. htmlentities()
B. addslashes()
C. stripslashes()
D. strip_tags()
E: htmlspecialchars()
Answer: A, E
Answer: A, B
Answer: D
Answer: A, B
A. TRUE
B. FALSE
Answer: B
QUESTION NO: 153
Which of the following techniques ensures that a value submitted in a form can only be yes or no
?
A. Use a select list that only lets the user choose between yes and no .
B. Use a hidden input field that has a value of yes or no .
C. Enable the safe_mode configuration directive.
D. None of the above.
Answer: D
A. addslashes()
B. htmlentities()
C. htmlspecialchars()
D. strip_tags()
E: quotemeta()
Answer: A, E
A. TRUE
B. FALSE
C. ENT_QUOTES
D. ENT_NOQUOTES
E: ENT_COMPAT
Answer: C
A. html_display
B. error_reporting
C. display_errors
D. error_log
E: ignore_repeated_errors
Answer: C
A. $_POST
B. $_SESSION
C. $_GET
D. $_SERVER
Answer: B
Answer: D
Answer: B
Answer: A, B
Answer: A, C
Answer: A, D
QUESTION NO: 163
Which technique should be used to speed up joins without changing their results?
Answer: A
Which of the following SimpleXML calls prints the name of the second book?
(Let $xml = simplexml_load_file("books.xml"); .) (Choose 2)
A. echo $xml->books->book[2];
B. echo $xml->books->book[1];
C. echo $xml->book[1];
D. echo $xml->xpath("/books/book[@id=2]");
E: $c = $xml->children(); echo $c[1];
Answer: C, E
A. getElementById()
B. getElementsByTagName()
C. getElementsByTagNameNS()
D. getElementByName()
E: findTag()
Answer: B
A. getAttributeNS()
B. getAttribute()
C. hasAttribute()
D. hasAttributeNS()
Answer: C
Answer: childNodes
A. save()
B. saveFile()
C. saveXML()
D. saveHTML()
E: saveHTMLFile()
Answer: B
A. It has to be well-formed.
B. It has to be valid.
C. It has to be associated to a DTD.
D. It may only contain UTF-8 encoded characters.
Answer: A, B
Answer: D
A. An XML declaration
B. A root element
C. A specified encoding
D. A reference to either a DTD or an XML schema definition
Answer: B
A. A single function
B. A single method from a class
C. All methods from a class
D. All classes defined in a script
Answer: A, C
QUESTION NO: 173
Which of the following statements about SOAP is NOT true?
Answer: C
A. simplexml_load_file()
B. simplexml_load_string()
C. load()
D. loadFile()
E: loadXML()
F: None of the above.
Answer: A
<?xml version='1.0'?>
<document>
<bar>
<foo>Value</foo>
</bar>
</document>
A. $xml->bar['foo']
B. $xml->bar->foo
C. $xml['document']['bar']['foo']
D. $xml->document->bar->foo
E: $xml->getElementByName('foo');
Answer: B
A. SAX
B. DOM
C. XPath
D. Push/Pull Approach
E: Expat
Answer: B
A. $xml->getElementById('2');
B. $xml->foo->bar->baz[2]['id']
C. $xml->foo->baz[2]['id']
D. $xml->foo->bar->baz[1]['id']
E: $xml->bar->baz[1]['id']
Answer: E
Answer: A
A. xpathQuery()
B. xpath()
C. simpleXMLXpath()
D. query()
E: evaluate()
Answer: B
Answer: E
A. load()
B. loadXML()
C. loadHTML()
D. loadHTMLFile()
Answer: D
A. 0
B. 1
C. 2
D. 6
E: 7
Answer: B
Answer: C
Answer: D
A. in_array('key', array_keys($a))
B. isset($a['key'])
C. array_key_exists('key', $a)
D. None of the above
Answer: B
A. implements ArrayAccess
B. has a public __count() method
C. was cast to an object from an array
D. None of the above
Answer: D
Answer: true
array_combine(array("A","B","C"), array(1,2,3));
A. array("A","B","C",1,2,3)
B. array(1,2,3,"A","B",C")
C. array("A"=>1,"B"=>2,"C"=>3)
D. array(1=>"A",2=>"B",3=>"C")
E: array(1,2,3)
Answer: C
$array = array("Sue","Mary","John","Anna");
A. array_rand($array);
B. array_rand($array, 1);
C. shuffle($array);
D. $array[array_rand($array)];
E: array_values($array, ARRAY_RANDOM);
Answer: D
A. array_flip()
B. array_reverse()
C. rsort()
D. krsort()
E: array_multisort()
Answer: B
$array = array(1,2,3);
while (list(,$v) = each($array));
var_dump(current($array));
A. bool(false)
B. int(3)
C. int(1)
D. NULL
E: Array
Answer: A
A. 4
B. 5
C. 8
D. None of the above
Answer: C
A. array_shift()
B. array_pop()
C. array_pull()
D. array_unshift()
Answer: A
A. implements ArrayAccess
B. implements Iterator
C. implements Iterator and ArrayAccess
D. None of the above
Answer: C
$text = <<<EOT
The big bang bonged under the bung.
EOT;
Answer: C
Answer: A
A. parse_url()
B. url_parse()
C. get_url_parts()
D. geturlparts()
Answer: A
Answer: C
printf('%010.6f', 22);
A. 22
B. 22.00
C. 022.000000
D. 22.000000
Answer: C
QUESTION NO: 200
What is the output of the following code?
Answer: B
A. echo $test(3);
B. echo $test[2];
C. echo $test(2);
D. echo $test{2};
E: echo $test{3};
Answer: B, D
preg_match('/^\d+(?:\.[0-9]+)?$/', $test);
Answer: B
QUESTION NO: 203
You need to escape special characters to use user input inside a regular expression. Which
functions would you use? (Choose 2)
A. addslashes()
B. htmlentities()
C. preg_quote()
D. regex_quote()
E: quote_meta()
Answer: C, E
A. 1
B. 2
C. 3
D. 4
Answer: C
A. 2
B. 3
C. 4
D. 7
E: 9
Answer: D
A. $_GET['ALL']
B. $_SERVER['QUERY']
C. $_SERVER['QUERY_STRING']
D. $_ENV['QUERY']
E: $QUERY_STRING
Answer: C
Answer: D
A. 2
B. 3
C. 4
D. 0
E: 1
Answer: B
A. -1
B. 1
C. TRUE
D. 0
E: FALSE
Answer: D
A. strip_tags()
B. htmlentities()
C. htmltidy()
D. htmlspecialchars()
E: showhtml()
Answer: B, D
A. 0
B. 3
C. 4
D. 5
Answer: C
$test = '/etc/conf.d/wireless';
substr($test, strrpos($test, '/')); // note that strrpos() is being called, and not strpos()
A. ""
B. "/wireless"
C. "wireless"
D. "/conf.d/wireless"
E: "/etc"
Answer: B
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)
Answer: B, D
A. header()
B. headers()
C. headers_list()
D. headers_sent()
E: getresponseheaders()
Answer: C
Answer: D
<form method="post">
<input type="checkbox" name="accept" />
</form>
In the server-side PHP code to deal with the form data, what is the value of $_POST['accept'] ?
A. accept
B. ok
C. true
D. on
Answer: D
Answer: B
<form method="post">
<select name="list">
<option>one</option>
<option>two</option>
<option>three</option>
</select>
</form>
In the server-side PHP code to deal with the form data, what is the value of $_POST['list'] ?
A. 1
B. 2
C. two
D. null
Answer: C
Answer: C
The user clicks on the image to submit the form. How can you now access the relative
coordinates of the mouse click?
Answer: D
What are two reasons to use POST instead of GET when submitting a form? (Choose 2)
Answer: AB
Answer: B
Answer:
Which of the following values for the Ss parameter do NOT yield a type error when calling the
doSomethingO function? A
A. 'null'
B. null
C. "
D. All of the above
Answer:
$a = 1;
$b - 2;
$c = 3;
print (++$a) + ($b++) + (++$c) + ($a++) + (++$b> + ($c++);