1h 30m 00s
ID: 22
Mark works as a Web Developer for Unicorn Inc. He develops an application in PHP using the following code:
switch(1) { case 1: print("Book Details"); case 2: print("Book Author"); default: print("Missing Book"); }
What will be the output of the script?
ID: 706
When dealing with cloned objects in PHP, which of the following statements are true ?
// As of PHP 7.0.0, members of cloned objects can be accessed in a single expression without any assignments... Like this: $dateTime = new DateTime(); echo (clone $dateTime)->format('Y');
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: 778
Give the following code?
try { // ... } catch (MyEx1 $e) { logError($e); } catch (MyEx2 $e) { logError($e); } catch (MyEx3 $e) { logError($e); }
Since all "catch" blocks have the same code, how can you avoid duplication here?
ID: 128
Which of the following streams is used to access the compressed data?
ID: 228
You run the following PHP script:
$x = 'john'; echo substr_replace($x, 'jenny', 0, 0);
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: 157
Which of the following is used to convert a scalar value into a single-quote delimited string that can be used safely as a single argument for a shell command?
mysql_escape_string()
escapeshellcmd()
mysql_real_escape_string()
escapeshellarg()
ID: 197
What will be the output of the following PHP script?
$dom = new DOMDocument(); $dom->load('book.xml'); $a = $dom->documentElement; print_r($a);
ID: 179
Which of the following functions can you use to mitigate a command injection attack? Each correct answer represents a complete solution. (Choose two)
strip_tags()
htmlentities()
ID: 199
Which of the following was not a built-in terminology before PHP5?
ID: 260
You are using a database named SalesDB to keep all sales records. The SalesDB database contains a table named Orders. You are required to create a new table named OldOrders and transfer all the data from the Orders table to the new table. Which of the following statements will you use to accomplish the task?
IMPORT INTO
ADD INTO
INSERT INTO
SELECT INTO
ID: 43
Which of the following files can be used to modify PHP configurations?
ID: 615
How does one create a cookie which will exist only until the browser session is terminated?
ID: 670
If you wanted a variable containing the letters A through Z, that allowed you to access each letter independently, which of the following approaches could you use?
ID: 738
Your PHP scripts is repeatedly parseing 50kb of data returned from a remote web service into browser-redable HTML. Users complain that the script takes a long time to run. Which of the following measures usually leads to the best results? (Choose 2)
ID: 169
Which of the following settings will you use to secure your application? Each correct answer represents a complete solution. (Choose all that apply)
ID: 231
What will be the output of the following PHP code snippet?
echo <<<"FOOBAR" Hello World! FOOBAR;
ID: 129
What is the output of the following code?
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: 98
You have been given the following PHP script:
$a = 'somevalue'; $array = ["a" => "One", "b" => "Two", "c" => "Three"]; // ???? echo "\$a = $a; \$b = $b; \$c = $c;";
What should you write at line number 3 to get the following output? $a = One; $b =Two; $c = $Three;
implode($array);
asort($array);
extract($array);
ksort($array);
ID: 551
When connecting to a database using PDO, what must be done to ensure that database credentials are not compromised if the connection were to fail?
ID: 687
Which of the following functions are part of PHP's internal Iterator interface?
valid()
rewind()
key()
next()
ID: 661
Which of the following are NOT valid ways to embed a variable into a string?
$a = 'Value: $value';
$a = "Value: {$value}";
$a = "Value: $value";
$a = "Value: $value->getValue()";
ID: 286
What is the work of simplexml_import_dom() in the following PHP code?
$dom = new domDocument; $dom->loadXML('<email><from>John</from></email>'); $xml = simplexml_import_dom($dom); echo $xml->from;
ID: 283
You have the following code in the welcome.html file:
<form action="welcome.php" method="post"> Your Name: <input type="text" name="fname" /> Your Girl Friend Name: <input type="text" name="fname" /> <input type="submit" /> </form>
The PHP code of the welcome.php file is as follows:
ID: 800
Which of the following statements about exceptions is NOT true?
ID: 67
You run the following script:
$a = 6 - 10 % 4; echo $a;
What will be the output?
ID: 212
Fill in the blank with the appropriate PHP function. The __ function is used to return the sum of the values of every entry within an array. *Exact matching is required.
ID: 451
What would happen when the following code was run?
define('Tree', 'oak'); echo 'This tree is: ' . tree;
ID: 700
What is the output of the code below ?
namespace animals; ini_set('error_reporting', E_ALL); ini_set('display_errors', 'on'); class Cat { static function Definition() { return 'Cats are ' . __NAMESPACE__; } } namespace animals\pets; class Cat { static function Definition() { return 'Cats are ' . __NAMESPACE__; } } echo Cat::Definition();
ID: 387
What is the output of the following PHP script?
$cars = ['year' => 2010, 'make' => 'Porsche', 'model' => 911]; while ($value = next($cars)) { echo $value; }
ID: 395
$values = array(37, 5, "09"); $sorted = sort($values, SORT_STRING); foreach ($sorted as $v) { echo $v; }
ID: 509
Which of the following is not a valid fopen() access mode:
ID: 247
Angela works as a Database Administrator for AznoTech Inc. She writes the following query:
SELECT Dept_Name, Emp_Name FROM Departments d1, Employees e1 WHERE d1.Dept_No = e1.Dept_No ORDER BY Dept_Name, Emp_Name;
Which of the following joins is used in this query?
ID: 321
$a = array('z', 'x'); $b = array('y', 'w'); $c = array('a' => 1, 'b' => 2); $d = array('c' => 3, 'd' => 4); $e = $a + $b; $f = $c + $d; foreach ($e as $value) { echo $value; } foreach ($f as $value) { echo $value; }
Enter the exact script output
ID: 599
Which of the following functions allow you to introspect the call stack during execution of a PHP script?
ID: 607
What would go in place of ?????? below to make this script execute without a fatal error?
$a = 1; $b = 0; /* ?????? */ $c = $a / $b;
exit();
quit();
die();
__halt_compiler();
ID: 549
What is the output of the following PHP code?
define('FOO', 10); $array = array(10 => FOO, "FOO" => 20); print $array[$array[FOO]] * $array["FOO"];
ID: 215
Fill in the blank with the appropriate function name. The _____ function is used to encode a string/array into a json encoded string.
encode()
json_decode()
decode()
json_encode()
ID: 114
class Test { function __call( $var1, $var2) { $check = " '$var1' called\n"; $check.= print_r($var2, true); return $check; } } $item = new Test(); print $item->xxx( "John", "Maria", "Jason" );
What is the work of the __call() method in the above script?
ID: 144
Which of the following OOP`s design patterns is used to encapsulate a data source so that accessing data source components becomes hidden within the class that implements the pattern?
ID: 508
If a function expects a parameter of type iterable, what can you do to send an object?
ID: 653
function byReference(&$variable = 0){ echo ++$variable; } byReference(); byReference();
ID: 59
<php echo (int) "Jason 1235";
ID: 122
Which of the following error constants gives all errors and warnings, except the E_STRICT error level?
E_ALL
E_ERROR
E_WARNING
E_RECOVERABLE_ERROR
ID: 477
Which of the following php configuration directives were deprecated in PHP 5.3 (tick as many as apply)?
ID: 340
What is the output of the following script?
$str = "Hello"; if ($str == "Hello") { echo "a"; } else if ($str == "Goodbye") { echo "b"; } elseif ($str == "Hello") { echo "c"; } else echo "d";
ID: 151
Which of the following data types cannot be directly manipulated by the client?
ID: 473
Which of the following are true (choose three)?
ID: 554
What does the following PHP script accomplish?
$dom = new DomDocument(); $dom->load('test.xml'); $body = $dom->documentElement->getElementsByTagName('body')->item(0); echo $body->getAttributeNode('background')->value. "\n";
ID: 642
What does the following code print?
function gen() { yield 1; yield 2; return 13; } foreach (gen() as $item) { echo $item; }
ID: 671
To force a user to redirect to a new URL from within a PHP 5 script, which of the following should be used?
ID: 61
Which of the following functions allows you to stack several error handlers on top of each other?
set_error_handler()
error_handler()
setError()
errorHandler()
ID: 475
How would you efficiently extract data from a csv file which is several gigabytes in size?
ID: 249
You work as a Database Administrator for Dolliver Inc. The company uses an Oracle database. The database contains two tables, named Employees and Departments. You want to retrieve all matched and unmatched rows from both the tables. Which of the following types of joins will you use to accomplish this?
ID: 805
What is displayed when the following code is executed?
$a = ['a' => 20, 1 => 36, 40]; array_rand($a); echo $a[0];
ID: 82
$array = array(1.1 => '1', 1.2 => '1'); echo count($array);
ID: 188
Consider the following script:
echo strtotime("january 1, 1901");
What will be the output of the above PHP script if older versions of glibc are present in the operating system?
ID: 84
Which of the following functions returns an array containing all the values of first array that are present in all the arguments?
array_keys()
array_map()
array_intersect()
array_key_exists()
ID: 357
What is the function used to define a custom error handling function?
ID: 589
What combination of boolean values for $a, $b, $c, and $d will result in the variable $number being equal to 3?
$a = null; $b = null; $c = null; $d = null; if($a && !$b) { if(!!$c && !$d) { if($d && ($a || $c)) { if(!$d && $b) { $number = 1; } else { $number = 2; } } else { $number = 3; } } else { $number = 4; } } else { $number = 5; }
ID: 466
What does the html_errors configuration directive do?
ID: 459
Which of the following statements are true when applied to a Registry pattern? (choose two)
ID: 311
Which of the statements below best describe the following PHP code. Note that backticks are being used (not single quotes).
$output = `ls`;
ID: 303
Which of the following functions will you use to change the number of bytes to buffer?
ob_start()
ob_buffer_start()
stream_set_write_buffer()
buffer_start()
ID: 257
Which of the following joins retrieves all rows from one table and only the matching rows from the joined table?
ID: 276
<?php if ($_POST) { echo '<pre>'; echo htmlspecialchars(print_r($_POST, true)); echo '</pre>'; } ?> <form action="action.php" method="post"> Name: <input type="text" name="personal[name]" /> Email: <input type="text" name="personal[email]" /> Code: // ??? <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> </select> <input type="submit" value="submit me!" /> </form>
Which of the following is the correct syntax that should be used in line number 10 to capture all of the data from the user in PHP?
<select multiple name="select_box=array()">
<select multiple name="select_box[]">
<select multiple name="select_box[multiple]">
<select multiple name="select_box">
ID: 12
<?= strtotime("january 1, 1901"); ?>
What will be the output of the above PHP script if the older versions of glibc are present in the operating system?
ID: 318
$a = 25; echo $a % 10;
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 )
# The script will throw an error message.
Array ( [0] => 4 [1] => 8 [2] => 12 )
Array ( [0] => 1 [1] => 2 [2] => 3 )
ID: 21
define('FOO', 10); $array = array(10 => FOO,"FOO" => 20); print $array[$array[FOO]] * $array["FOO"];
ID: 111
Which of the following functions will you use to sort the values of an array object by preserving key values?
ArrayObject::sort
ArrayObject::rsort
ArrayObject::asort
ArrayObject::keysort
ID: 600
The ____ construct is particularly useful to assign your own variable names to values within an array.
ID: 366
The array_search() function is used to determine the array key for a given value. If the value is not found then false is returned. What is the output of the following PHP script?
$values = [15, 12, "15", 34, 15 => 25]; $key = array_search("15", $values); if (!$key) { echo "Not found"; } else { // gettype() will return either 'string' or 'integer' echo $key . ' - ' . strtolower(gettype($values[$key])); }
ID: 434
Which of the following is a valid way to pass the $callback parameter expected by array_walk()? (choose three)