1h 30m 00s
ID: 684
The following is a common XML structure used in service oriented architectures, what does it represent?
<?xml version="1.0"?> <methodCall> <methodName>myMethod</methodName> <params> <param> <value><string>HI!</string></value> </param> </params> </methodCall>
ID: 209
All variables in PHP start with which symbol?
ID: 543
Which of the following is not a valid default stream wrapper for PHP 5, assuming OpenSSL is enabled?
ID: 744
What is the output of the following code?
$str = printf('%.1f', 7.1); echo 'Zend PHP Certification '; echo $str;
ID: 466
What does the html_errors configuration directive do?
ID: 149
Which of the following functions will you use as a countermeasure against a SQL injection attack?
mysql_fetch_array()
escapeshellcmd()
escapeshellarg()
mysqli_escape_string()
ID: 406
What is the output of the following PHP script?
$str = 'stingers'; echo strtr($str, 'st', 'bl');
Enter the exact script output
ID: 278
Consider the following PHP code snippet:
<form method=get> <select name ="fruits" id="fruits"> <option value="1">Apple</option> <option>Orange</option> <option value="3">Strawberry</option> </select> <input type="submit" value="Submit"> <?= $_GET['fruits'] ?? ''; ?>
What will be the output if you select 'Orange' from the dropdown menu?
ID: 585
Consider the following PHP string representing an SQL statement:
$query = "UPDATE users SET password='$password' WHERE username='$username'";
Which of the following values for $username or $password would change the behavior of this query when executed?
ID: 637
What is the output of the following?
$a = 010; $b = 0xA; $c = 2; print $a + $b + $c;
ID: 185
Fill in the Blank with the appropriate method name. The ___ is used to import the SimpleXML objects for use with DOM. *Exact matching is required.
ID: 650
Consider the following function:
function redirect($url) { // Check to make sure we haven't already sent // the header: if(/*?????*/) { header("Location: $url"); } }
What conditional should replace the ????? above?
!header_location($url)
!in_array("Location: $url", headers_list())
$_SERVER['HTTP_LOCATION'] != $url
!header_exists("Location: $url")
ID: 217
Consider the following script:
$string1 = "ab"; $string2 = "cd"; $string1 = $string1 . $string2; $string3 = "abc"; $string1 .= $string3; echo $string1;
What will be the output of the above PHP script?
ID: 405
What is the output of the following script?
$name = 'Judy'; $str1 = <<<EOF Hello $name EOF; $str2 = <<<'EOF' Goodbye $name; EOF; if (strpos($str1, $name) === false) { echo 'a'; } else { echo 'b'; } if (strpos($str2, $name) === false) { echo 'c'; } else { echo 'd'; }
ID: 546
function a($number) { return (b($number) * $number); } function b(&$number) { return ++$number; } echo a(5);
ID: 584
Which key will not be displayed from the following code block?
$array = ['a' => 'John', 'b' => 'Coggeshall', 'c' => ['d' => 'John', 'e' => 'Smith']]; function display($item, $key) { print "$key => $item\n"; } array_walk_recursive($array, "display");
ID: 343
$myArray = array('a', 'b', 'c'); foreach ($myArray as $k => $v) { echo $v; for ($i = 1; $i < 5; $i++) { if ($i == $k) { break(2); } echo $i; } }
ID: 533
$dom = new DOMDOcument(); $dom->load('0138.xml'); foreach($dom->documentElement->childNodes as $child) { if(($child->nodeType == XML_ELEMENT_NODE) && $child->nodeName == "item") { foreach($child->childNodes as $item) { if(($item->nodeType == XML_ELEMENT_NODE) && ($item->nodeName == "title")) { print "{$item->firstChild->data}\n"; } } } }
Assuming the referenced XML document exists and matches the parsing logic, what should be displayed when this script is executed?
ID: 437
What would you expect to get from PDOStatement::fetch() in its default mode?
ID: 798
What will be the output after the code runs?
function doSomething($a, $b) { return $a / $b; } try { doSomething(1); } catch (Exception $ex) { echo 1; } catch (ArgumentCountError $ace) { echo 2; } catch (DivisionByZeroError $dbze) { echo 3; }
an error
1
3
2
ID: 38
Which of the following PHP variable names is not a valid variable name?
$var
$_2var
$__var
$2var
ID: 258
Which of the following joins will you use to display data that do not have an exact match in the column?
ID: 314
$a = ($b = 13) - 5; echo $a . ' - ' . $b;
ID: 618
function _1dotEach($n) { if ($n > 0) { _1dotEach(--$n); echo "."; } else { return $n; } } _1dotEach(4);
ID: 295
What does the second parameter of the file_get_contents() function do?
ID: 158
Which of the following are the countermeasures of the remote code injection? Each correct answer represents a complete solution. Choose all that apply.
ID: 348
What is the difference between including a script with include() and require()?
ID: 547
function a(&$apples) { $apples++; } $oranges = 5; $apples = 5; a($oranges); echo "I have $apples apples and $oranges oranges";
ID: 243
You have been given the following code snippet:
$stmt = $dbh->prepare("SELECT * FROM USER where name = ?"); if ($stmt->execute(array($_GET['name']))) { while (??????) { print_r($row); } }
What will you write at line number 4 to fetch data from database?
$row = $stmt->get()
$row = $stmt->fetch()
$row = $stmt->fetchall()
$row = $stmt->getch()
ID: 534
When is it acceptable to store sensitive information in an HTTP cookie?
ID: 481
What does the chr() function do?
ID: 335
$number = 100; echo $number < 10 ? "a" : ($number > 100 ? "b" : "c");
ID: 97
Which of the following statements will return the second parameter passed to a function?
func_num_args(2);
func_get_args(2);
func_num_args(1);
func_get_arg(1);
ID: 334
define('MYCONSTANT', 0); if (empty(MYCONSTANT)) { echo "Hello"; } else { echo "Goodbye"; }
ID: 467
$a = 1; function calculate() { global $a; $a += 7; $a = $a * 043; return --$a; } echo $a;
ID: 142
Fill in the blank with the appropriate word. The ____ operator lets a programmer inspect all of the ancestor classes of the object, as well as any interfaces.
ID: 588
The __ keyword is used to indicate an incomplete class or method, which must be further extended and/or implemented in order to be used.
ID: 498
How would you change a SimpleXMLElement object into a DOMElement? (choose two)
ID: 372
What is the primary difference between array_key_exists() and isset() when checking to see if a given array element exists?
ID: 204
Fill in the blank with the appropriate function name. The ___ function is used to decode a json encoded string/array.
join()
xml_decode()
json_decode()
json_endcode()
ID: 141
Which of the following methods is called to directly echo or print() an object?
__toString()
__unset()
__isset()
__set_state()
ID: 225
Consider the following string:
ZeNd php
After running a PHP script, the above string is converted in the following format:
$string1= "ZeNd php"; $string1= strtolower($string1); echo strrev($string1);
$string1= "ZeNd php"; $string1= trim($string1); echo stringrev($string1);
$string1= "ZeNd php"; $string1= str_to_lower($string1); echo strev($string1);
$string1= "ZeNd php"; $string1= strtolower($string1); echo stringrev($string1);
ID: 129
class A {}; class B1 extends A {}; class_alias('A', 'B2'); $b1 = new B1; echo get_class($b1); $b2 = new B2; echo get_class($b2);
ID: 418
Using nl2br() is a handy way to format plain-text for output in a HTML document. What is the output of the following PHP script?
$str = nl2br("foo\nbar"); # nl2br doesn't remove the \n $str = str_replace("\n", "", $str); echo nl2br($str);
ID: 635
When executing system commands from PHP, what should one do to keep applications secure?
ID: 269
Which of the following code snippets will you use to redirect your users from one page to another?
header("http://php.com");
redirect("http://php.com");
header("Location: http://php.com");
redirect("Location: http://php.com");
ID: 313
What is output of the following PHP script?
$str = 'foo'; $str .= 'bar'; $num = 0; $num += 25; $num -= 15; echo $str . ' - ' . $num;
ID: 403
What is the key difference between Heredoc and Nowdoc syntax?
ID: 411
$html = '<p>line1line2</p>'; echo strip_tags($html, 'br');
ID: 604
function oranges($oranges = 17) { $oranges .= 1; } $apples = 5; oranges($apples); echo ++$apples;
ID: 617
When writing CLI scripts it is often useful to access the standard streams available to the operating system such as standard input/output and error. How does one access these streams in PHP 5/7?
ID: 138
Which of the following is triggered when inaccessible methods are triggered in an object context?
__test()
__load()
__call()
__autoload()
ID: 379
In the following code, what are the values required in $a, $b, $c and $d to output 40?
$values = array( array( 1 => 10, 20, array(30, array(40)) ), array( 2 => 50, array( array(1 => 60, 0 => 70) ) ) ); echo $values[$a][$b][$c][$d];
ID: 239
Consider the following PHP script:
$charlist = [ 'a' => 'one', 'b' => 'two', ]; // *****
What statement will you write at line number 5 instead of ***** to get the output onectwo?
echo strip_tags('acb', $charlist);
echo strstr('acb', $charlist);
echo strtr('acb', $charlist);
echo strtok('acb', $charlist);
ID: 230
Consider the following array:
$arr = ['apple', 'banana', 'cherry'];
Which function would you use to get the following string?
implode()
substr()
ltrim()
explode()
ID: 171
Which of the following functions wraps a string to a given number of characters?
ID: 168
Which of the following functions will you use to get the following output of string "Hello world!"?
"!dlrow olleH"
strops()
stripos()
strrev()
strrchr()
ID: 37
What is the output of the following code snippet?
$a = 20; function myfunction($b) { $a = 30; global $a, $c; return $c = ($b + $a); } print myfunction(40) + $c;
ID: 259
You want to check whether the header has already been sent or not. Which of the following code segments will you use to accomplish the task?
ID: 56
You run the following PHP script:
$a = 20 % -8; echo $a;
ID: 70
$array1 = array ('a' => 20, 30, 35); $array2 = array ('b' => 20, 35, 30); $array = array_intersect_assoc($array1, $array2); var_dump($array);
What will be the output?
array(0) { }
array(3) { ["'a'"]=> int(20) [0]=> int(30) [1]=> int(35) }
The script will throw an error message.
array(1) { ["'a'"]=> int(20)}
ID: 107
You have been given the following PHP code snippet:
$array = array('1', '2', '3'); foreach($array as $key => $value) { $value = 4; } print_r($array);
Array ( [0] => 1 [4] => 2 [8] => 3 )
Array ( [0] => 1 [1] => 2 [2] => 3 )
# The script will throw an error message.
Array ( [0] => 4 [1] => 8 [2] => 12 )
ID: 4
What will be the output when you try to run the script below?
$b = false; if ($b = true) { print("true"); } else { print("false"); }
ID: 571
When working with SimpleXML in PHP 5, the four basic rules on how the XML document is accessed are which of the following?
ID: 54
Which of the following is NOT a strongly typed language?
ID: 804
function func($x, $x = 2, $x = 3) { return $x; } echo func(3);
ID: 380
How do you remove an element with the key 0 from the array $numbers?
$numbers[0] = null;
array_pop($numbers);
array_shift($numbers);
unset($numbers[0]);
ID: 611
Which of the following functions could be used to break a string into an array?
array_split()
string_split()
preg_match_all()
ID: 509
Which of the following is not a valid fopen() access mode:
ID: 135
Assuming every method call below returns an instance of an object, how can the following be re-written in PHP5/7?
$a = new MyClass(); $b = $a->getInstance(); $c = $b->doSomething();
$c = ((MyClass)$a->getInstance())->doSomething();
$c = $a->getInstance()->doSomething();
$c = (MyClass)$a->getInstance();
ID: 693
What is the default value for the "max_execution_time" setting when running PHP as a CLI SAPI ?
ID: 728
Is there a way to make E_NOTICE type errors behave like fatal errors in PHP and therefor stop script execution when such an error occurs ?
ID: 90
$a = 5; $b = 10; function Mul() { $GLOBALS['b'] = $GLOBALS['a'] * $GLOBALS['b']; } Mul(); print($b);
ID: 688
Why is it important from a security perspective to never display PHP error messages directly to the end user, yet always log them?
ID: 579
What does the following code print?
$a = 'aaaa'; $b = 'bbbb'; echo $a ?? $b ?? 'cccc';