1h 30m 00s
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: 470
Given the following code:
Interface Verifiable { public function verify(); } Class Cheque { public function verify() { return true; } } Class CurrencyCheque extends Cheque implements Verifiable { // interesting stuff happens } $obj = new CurrencyCheque();
What happens when we instantiate a CurrencyCheque object?
ID: 464
Which of the following is a valid namespace operator in PHP?
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()
json_encode()
decode()
ID: 291
Fill in the blank with the appropriate function(). The ___ function is used to copy data from one stream to another. It is mainly useful in copying data between two open files. *Matching is case-insensitive.
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: 352
What is the output of the following script?
$number = 25; if ($number <= 25) { echo "lte"; } else if ($number == 25) { echo "e"; } else if ($number >= 25) { echo "gte"; } else { echo "o"; }
Enter the exact script output
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_exists("Location: $url")
!header_location($url)
!in_array("Location: $url", headers_list())
$_SERVER['HTTP_LOCATION'] != $url
ID: 628
Which of the following SQL statements will improve SQLite write performance?
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 stringrev($string1);
$string1= "ZeNd php"; $string1= str_to_lower($string1); echo strev($string1);
$string1= "ZeNd php"; $string1= trim($string1); echo stringrev($string1);
$string1= "ZeNd php"; $string1= strtolower($string1); echo strrev($string1);
ID: 346
What is the output of the following PHP script?
$myArray = array(1, 2, 3); for ($i = 0, $length = count($myArray); $i < $length; $i++) { echo $myArray[$i]; }
ID: 58
You run the following script:
<?php function odd() { for($i = 1; $i <= 50; $i = $i + 2) { echo "$i"; } } echo "The last value of the variable \$i: $i";
What will be the output?
ID: 43
Which of the following files can be used to modify PHP configurations?
ID: 360
What is the output of the following PHP script.
$int1 = 25; $int2 = 10; $int3 = ceil($int1 / $int2); $int4 = ceil((int) ($int1 / $int2)); echo $int3 . ' - ' . $int4;
ID: 96
$array1 = array ("a", "b", "c", "d", "e", "f"); $array2 = array_slice($array1, 2, 2); foreach ( $array2 as $val ) { print "$val "; }
ID: 707
Which of the following statements about object serialization are true ?
ID: 486
What does the following code output?
$i = function($j) { $i = $j + 4; return $i++; }; $j = 6; echo $i($j);
ID: 367
$arr1 = ['a' => 'Apple', 'b' => 'Banana']; $arr2 = ['b' => 'Banana', 'a' => 'Australia', 'Apple']; $arr3 = array_diff($arr1, $arr2); $arr4 = array_diff($arr2, $arr1); $keys = array_keys($arr4); echo count($arr3) . ' - ' . $keys[0];
ID: 620
For an arbitrary string $mystring, which of the following checks will correctly determine if the string PHP exists within it?
if (strpos($mystring, "PHP") === true)
if (strpos($mystring, "PHP") !== false)
if (!strpos($mystring,"PHP"))
if (strloc($mystring, "PHP") == true)
ID: 40
Assume that today is January 8th, 2013, 5:16:18 pm in MST time zone.
<?php echo date('l \t\h\e jS');
ID: 272
Which of the following header codes is used for redirection?
ID: 131
Maria creates an application using PHP script. The application contains certain classes. The class design requires that a particular member variable must be directly accessible to any subclass of this class only. What should Maria do to achieve this?
ID: 192
Which of the following functions can you use to add data? Each correct answer represents a complete solution. Choose all that apply.
DomElement::setAttribute()
DomNode::cloneNode()
DomNode::insertBefore()
DomNode::appendChild()
ID: 256
You want to retrieve all the data from any given table. You also want to ensure that no duplicate values are displayed. Which of the following SQL statements will you use to accomplish the task?
ID: 802
If a function signature contains three parameters, for which of them may the splat operator be used?
ID: 113
Which of the following keywords is used to prevent a method/class to be overridden by a subclass?
ID: 648
Which of the following php.ini directives should be disabled to improve the outward security of your application?
ID: 722
Considering the table structure below what MySQL query will load a result set containing all students names enrolled in the programming classes ?
--students table: | studentid | name | -------------------- | 1 | Mike | | 2 | John | | 3 | Jeff | | 4 | Anne | --classes table: | classid | classname ------------------------- | 1 | Math | 2 | Programming | 3 | Biology classes_to_students table: | studentid | classid ------------------------- | 1 | 1 | 2 | 2 | 3 | 2 | 4 | 3
SELECT s.name FROM students as s INNER JOIN classes as c ON s.studentid = c.classid INNER JOIN classes_to_students as cs ON s.studentid = cs.studentid WHERE c.classname = 'Programming';
-- none
SELECT s.name FROM students as s WHERE s.studentid IN ( SELECT studentid FROM classes_to_students as cs INNER JOIN classes as c ON cs.classid = c.classid WHERE c.classname = 'Programming' );
SELECT s.name FROM students as s INNER JOIN classes_to_students as cs ON s.studentid = cs.studentid INNER JOIN classes as c ON c.classid = cs.classid WHERE c.classname='Programming';
ID: 139
Which of the following functions will sort an array in ascending order by value, while preserving key associations?
asort()
ksort()
krsort()
usort()
ID: 56
You run the following PHP script:
$a = 20 % -8; echo $a;
ID: 626
Setting a HTTP cookie on the client which is not URL-encoded is done how in PHP 5?
ID: 561
Using flock() to lock a stream is only assured to work under what circumstances?
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: 768
What is the output of the following code?
class A { public function __call($f, $arg){ return static::who(); } public static function who() { echo __CLASS__; } } class B extends A { public static function who() { echo __CLASS__; } } $b = new B(); echo $b->test();
ID: 255
You have to select persons whose age is between twenty-five and forty from a database named HumanResource. Which of the following criteria will you use in the query to accomplish the task?
ID: 134
You want to save a client's session values in a database. Which of the following actions will you take to accomplish this task?
ID: 801
What is the ouput of the following code?
class Magic { public $a = "A"; protected $b = ["a" => "A", "b" => "B", "c" => "C"]; protected $c = [1, 2, 3]; public function __get($v) { echo "$v,"; return $this->b[$v]; } public function __set($var, $val) { echo "$var: $val,"; return $this->$var = $val; } } $m = new Magic(); echo $m->a . "," . $m->b . "," . $m->c . ","; $m->c = "CC"; echo $m->a . "," . $m->b . "," . $m->c;
ID: 500
By default PHP stores its sessions on the web server's filesystem. What function is used to tell PHP to use your custom session storage handler?
ID: 280
What is the maximum limit of the file size that a user can upload according to the code snippet given below?
<form enctype="multipart/form-data" action="index.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="5000" /> <input name="filedata" type="file" /> <input type="submit" value="Send file" /> </form>
ID: 624
A fingerprint of a string can be determined using which of the following?
ID: 687
Which of the following functions are part of PHP's internal Iterator interface?
key()
rewind()
valid()
next()
ID: 80
$array1 = array("a", "b", "c", "d", "e", "f"); $array2 = array_slice($array1, -3); foreach($array2 as $val) { print "$val "; }
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: 453
$a = 42 & 05 + 17; echo $a;
ID: 219
What will be the output of the following PHP code?
$a = "hi,world"; $b = array_map("strtoupper", explode(",", $a)); foreach($b as $value) { print "$value"; }
ID: 186
Which of the following is used to retrieve the root element from an XML file?
XMLReader::expand()
XMLReader::close()
$dom->documentElement
XMLReader::getAttribute()
ID: 516
Consider the following code snippet:
$query = "INSERT INTO mytable (myinteger, mydouble, myblob, myvarchar) VALUES (?, ?, ?, ?)"; $statement = mysqli_prepare($link, $query); if (!$statement) { die(mysqli_error($link)); } /* The variables being bound to by MySQLi don't need to exist prior to binding */ mysqli_bind_param($statement, "idbs", $myinteger, $mydouble, $myblob, $myvarchar); /* ???????????? */ /* execute the query, using the variables as defined. */ if (!mysqli_execute($statement)) { die(mysqli_error($link)); }
Assuming this snippet is a smaller part of a correctly written script, what actions must occur in place of the ????? in the above code snippet to insert a row with the following values: 10, 20.2, foo, string ?
ID: 751
Consider the following snippet of code. What is the name of the function that needs to be inserted in the placeholder?
$dh = opendir("."); while ($file = _____($dh)) { echo $file; }
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: 763
Which of the following cannot be a part of the class definition?
ID: 736
Which PHP functions may be used to find out whitch PHP extension are available in the system? (Choose 2)
ID: 374
What is the output of the following PHP code?
$myArray = [0, NULL, '', '0', -1]; echo count(array_filter($myArray));
ID: 656
Creating new nodes in XML documents using PHP can be done using which XML/PHP 5 technologies?
ID: 775
What are the main advantages of replacing many fatal errors with Exceptions in PHP 7?
ID: 359
This question tests your knowledge of boolean values and casting. What is the output of the following PHP script.
$myInt = -1; $myBool = (bool) $myInt; if ($myBool > 0) { echo "5"; } else if ($myBool == true) { echo "6"; } else if (!$myBool) { echo "7"; } else { echo sprintf("%d", $myBool); }
ID: 423
$a = 0.5; $b = 0.1; $c = 16; echo sprintf('%01.2lf %.1lf 0x%x', $a, $b, $c);
ID: 499
What is the preferred way of writing the value 25 to a session variable called age?
session_register('age', 25);
$HTTP_SESSION_VARS['age'] = 25;
$age = 25; session_regiser('age');
$_SESSION['age'] = 25;
ID: 120
Which of the following are the uses of Reflection? Each correct answer represents a complete solution. Choose all that apply.
ID: 437
What would you expect to get from PDOStatement::fetch() in its default mode?
ID: 410
The parse_str() function is used to parse a query string just as if it were passed in the URL of a HTTP request. If the second argument is included then the parsed values are written to this variable. What is the output of the following script?
$str = "days=Mon&days=Wed" . "&fruit[1]=Apple&fruit[]=Banana&age=13"; parse_str($str, $output); // gettype will return 'array' or 'string' echo gettype($output['days']); echo ' - '; // array_search will return the key // where the first argument is located echo array_search('Banana', $output['fruit']); echo ' - '; echo array_key_exists('age', $output) ? $output['age'] : 0;
ID: 171
Which of the following functions wraps a string to a given number of characters?
ID: 371
Consider the following PHP code:
$myArray = [10, 20, 30, 40];
What is the simplest way to return the values 20 and 30 in a new array without modifying $myArray?
array_splice($myArray, 2, 1);
array_splice($myArray, 1, 2);
array_splice($myArray, 10, 20);
array_slice($myArray, 1, 2);
ID: 631
Consider the following simple PHP script:
$dom = new DomDocument(); $dom->load('test.xml'); $xpath = new DomXPath($dom); $nodes = $xpath->query(???????, $dom->documentElement); echo $nodes->item(0)->getAttributeNode('bgcolor')->value . "\n";
What XPath query should go in the ?????? above to display the "bgcolor" attribute of the first "body" node in the XML document?
ID: 430
What is the output of the following:
$m = 3; $n = 0; function l() { $m = 0; $m++; global $n; return array($n,$m); } echo implode((L(l())),',');
ID: 265
Which of the following HTML code snippets can be used for the file uploading?
<form enctype="multipart/form-data" action="index.php" method="post">
<form enctype="application/x-www-form-urlencoded" action="index.php" method="post">
<form enctype="plain" action="index.php" method="post">
<form enctype="text/plain" action="index.php" method="post">
ID: 95
What will be the output of the following code snippet?
$input = [4, "4", "3", 4, 3, "3", 3, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7]; echo count(array_unique($input));
ID: 251
Martin works as a Database Administrator for MTech Inc. He designs a database that has a table named Products. He wants to create a report listing different product categories. He does not want to display any duplicate row in the report. Which of the following SELECT statements will Martin use to create the report?
SELECT Product_No, Prod_Category FROM Products;
SELECT Product_No, Prod_Category FROM Products GROUP BY Product_No ORDER BY Product_No;
SELECT Product_No, Prod_Category FROM Products GROUP BY Product_No;
SELECT DISTINCT Product_No, Prod_Category FROM Products;
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: 717
Which PHP function(s) can be used to check if a variable is defined and is not NULL ?
ID: 231
What will be the output of the following PHP code snippet?
echo <<<"FOOBAR" Hello World! FOOBAR;
ID: 427
One way to format currencies in PHP is to use the built-in money_format() function. Before using it you must set the locale for the type of currency you're trying to format. What is the output of the following PHP script? The currency name for en_US is USD and uses $ as the currency symbol. Additionally, there are 100 cents to the dollar.
setlocale(LC_MONETARY, 'en_US'); $amt = 100; echo money_format('%.2n', $amt);
ID: 698
Considering the code below
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 ?
ID: 289
Which of the following file permissions is set by the tempnam() function for the newly created temp file?
ID: 357
What is the function used to define a custom error handling function?
ID: 574
Which of the following list of potential data sources should be considered trusted?