Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:697)

ID: 697


What is the output of the code below ?


                        
$now  = new DateTime();
$now2 = new DateTime();

$ago  = new DateInterval('P4Y10M3W');
$ago2 = new DateInterval('P4Y10M2W7D');

$then  = $now->sub($ago);
$date1 = $then->format('Y-m-d');

$then2 = $now2->sub($ago2);
$date2 = $then2->format('Y-m-d');

var_dump ($date1 === $date2);                    



Question: 2 (ID:777)

ID: 777


What will happen when the following code is executed?


                        
interface Additionable {
    public function add($x, $y);
}

function average ($a, $b) {
    $anon = new class implements Additionable {
        public function divide($x, $y) {
            return $x / $y;
        }
        public function add($x, $y) {
            return $x + $y;
        }
    };

    $sum = $anon->add($a, $b);
    $average = $anon->divide($sum, 2);
    return $average;
}
echo average(10, 70);                    



Question: 3 (ID:368)

ID: 368


Which of the following statements best describes the purpose of PHP's extract() function? This function accepts an array as its first argument.





Question: 4 (ID:385)

ID: 385


Consider the following PHP script, used to apply a callback function to every element of an array.


                        
function square($val) {
    return pow($val, 2);
}
$arr = [1, 2, 3, 4];
/** line **/
$i = 0;
foreach ($squares as $value) {
    if ($i++ > 0) {
        echo ".";
    }
    echo $value;
}                    

What line of code should be substituted with / line / to achieve an output of 1.4.9.16?



Question: 5 (ID:647)

ID: 647


Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?





Question: 6 (ID:457)

ID: 457


What is the output of the following code:


                        
function a($a) {
   echo $a . "&";
}
function b($a) {
   echo "-" . $a;
}
$a = "!";
$b = &$a;
echo a(b($b));                    



Question: 7 (ID:612)

ID: 612


Consider the following script:


                        
function func(&$arraykey) {
    return $arraykey; // function returns by value!
}
$array = array('a', 'b', 'c');
foreach (array_keys($array) as $key) {
    $y = &func($array[$key]);
    $z[] =& $y;
}
var_dump($z);                    

This code has changed behavior in PHP 5. Identify the output of this script as it would have been in PHP 4, as well as the new behavior in PHP 5.



Question: 8 (ID:70)

ID: 70


You run the following PHP script:


                        
$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?



Question: 9 (ID:440)

ID: 440


Which HTTP status code asks a user to provide credentials?





Question: 10 (ID:95)

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));                    



Question: 11 (ID:601)

ID: 601


What is the best measure one can take to prevent a cross-site request forgery (CSRF)?





Question: 12 (ID:201)

ID: 201


Fill in the blank with the appropriate function name. The ____ function is used to return the current time measured in the number of seconds since the Unix Epoch (January 1, 1970, 00:00:00 GMT). *Matching is case-insensitive.





Question: 13 (ID:268)

ID: 268


You want to send an HTTP cookie without URL encoding the cookie value. Which of the following functions will you use?





Question: 14 (ID:551)

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?





Question: 15 (ID:375)

ID: 375


What PHP function is used to return an array containing values present in two or more passed arrays?





Question: 16 (ID:763)

ID: 763


Which of the following cannot be a part of the class definition?





Question: 17 (ID:460)

ID: 460


Is this statement true or false? "Methods declared as static must be called statically"





Question: 18 (ID:456)

ID: 456


What is the output of this code:


                        
function c($a, $b = 1, $c) {
   return array($c, $a, $b);
}
list($a, $b, $c) = c(0,0,0);
echo $b;                    



Question: 19 (ID:643)

ID: 643


When implementing a permissions system for your Web site, what should always be done with regards to the session?





Question: 20 (ID:614)

ID: 614


What is the result of the following code snippet?


                        
$array = array(
    'a' => 'John',
    'b' => 'Coggeshall',
    'c' => array(
        'd' => 'John',
        'e' => 'Smith'
    )
);

function something($array) {
    extract($array);
    return $c['e'];
}

print something($array);                    



Question: 21 (ID:536)

ID: 536


To ensure that a given object has a particular set of methods, you must provide a method list in the form of an ____ and then attach it as part of your class using the ____ keyword.





Question: 22 (ID:532)

ID: 532


When an object is serialized, which method will be called, automatically, providing your object with an opportunity to close any resources or otherwise prepare to be serialized?





Question: 23 (ID:254)

ID: 254


Maria writes a query that uses outer join between two tables. Which of the following operators are not allowed in the query? Each correct answer represents a complete solution. Choose two.





Question: 24 (ID:642)

ID: 642


What does the following code print?


                        
function gen() {
    yield 1;
    yield 2;
    return 13;
}

foreach (gen() as $item) {
    echo $item;
}                    



Question: 25 (ID:191)

ID: 191


Which of the following protocols is normally used by Webservices?





Question: 26 (ID:590)

ID: 590


One can ensure that headers can always be sent from a PHP script by doing what?





Question: 27 (ID:355)

ID: 355


What is the primary reason for omitting the code ?> in a PHP script?





Question: 28 (ID:71)

ID: 71


What will be the output of the PHP script given below?


                        
$array1 = array("orange", "banana", "apple", "raspberry");
$array2 = array(0 => "pineapple", 4 => "cherry");
$array3 = array(0 => "grape");
$array4 = array_replace($array1, $array2, $array3);
print_r($array4);                    



Question: 29 (ID:773)

ID: 773


What is the result of the following code?


                        
<?= (function(){ return [$x, $x + 1, $x + 2];})(4)[2];                    



Question: 30 (ID:272)

ID: 272


Which of the following header codes is used for redirection?





Question: 31 (ID:768)

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();                    



Question: 32 (ID:141)

ID: 141


Which of the following methods is called to directly echo or print() an object?





Question: 33 (ID:360)

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;                    



Question: 34 (ID:464)

ID: 464


Which of the following is a valid namespace operator in PHP?





Question: 35 (ID:526)

ID: 526


Consider the following HTML fragement:


                        
<select name="?????" multiple>
    <option value="1">Item #1</option>
    <!-- ... more options ... -->
</select>                    

Which of the following name attributes should be used to capture all of the data from the user in PHP?



Question: 36 (ID:804)

ID: 804


What is the output of the following code?


                        
function func($x, $x = 2, $x = 3)   {
    return $x;
}
echo func(3);                    



Question: 37 (ID:498)

ID: 498


How would you change a SimpleXMLElement object into a DOMElement? (choose two)





Question: 38 (ID:646)

ID: 646


Which of the following functions is used to determine if a given stream is blocking or not?





Question: 39 (ID:218)

ID: 218


What are possible value of the following code, if $a and $b variable are defined in current scope script?


                        
echo ($a <=> $b);
                    



Question: 40 (ID:748)

ID: 748


Which function can be used to read and parse data from CSV file?





Question: 41 (ID:402)

ID: 402


The str_pad() function is used pad a string to a given length using another string. What is the output of the following PHP script?


                        
$number = 5;
$len    = 3;
$pad    = '0';
echo str_pad($number, $len, $pad, STR_PAD_LEFT);                    



Question: 42 (ID:623)

ID: 623


What is the output of the following code?


                        
class MyException extends Exception {}
class AnotherException extends MyException {}

class Foo {
    public function something() {
        throw new AnotherException();
    }
    public function somethingElse() {
        throw new MyException();
    }
}

$a = new Foo();

try {
    try {
        $a->something();
    } catch(AnotherException $e) {
        $a->somethingElse();
    } catch(MyException $e) {
        print "Caught Exception";
    }
} catch(Exception $e) {
    print "Didn't catch the Exception!";
}                    



Question: 43 (ID:344)

ID: 344


What is the output of the following script?


                        
$number = 15;
if ($number > 15);
    for ($i = 1; $i < 5; $i++)
        echo $i;

echo $number;                    



Question: 44 (ID:446)

ID: 446


What is the output of the following line of code?


                        
echo "4" + 05 + 011 + ord('a');                    



Question: 45 (ID:439)

ID: 439


What is PDO::query() equivalent to?





Question: 46 (ID:121)

ID: 121


Which of the following is used to pass an object?





Question: 47 (ID:279)

ID: 279


You have been given the following code snippet:


                        
<?php
 $string = <<<XML
 <?xml version="1.0" encoding="ISO-8859-1"?> 
 <email> 
 <to>[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</to> 
 <from>[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){fo                    

Which of the following code snippets will you write to print the XML content?



Question: 48 (ID:288)

ID: 288


Which of the following is an associative array of items uploaded by the current PHP script via the HTTP POST method?





Question: 49 (ID:654)

ID: 654


Which of the following aspects of the MVC pattern is used in conjunction with the database?





Question: 50 (ID:530)

ID: 530


___ can be used to add additional functionality to a stream, such as implementation of a specific protocol on top of a normal PHP stream implementation.





Question: 51 (ID:606)

ID: 606


How do you define an array in PHP7?





Question: 52 (ID:535)

ID: 535


Given the following XML document in a SimpleXML object:


                        
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>XML Example</title>
  </head>
  <body>
    <p>
      Moved to &lt;<a href="http://example.org/">http://www.example.org/</a>.&gt;
      <br/>
    </p>
  </body>
</html>                    

Select the proper statement below which will display the HREF attribute of the anchor tag.



Question: 53 (ID:447)

ID: 447


What is the output of the following?


                        
$a = 7;
$b = 4;
function b($a, $b) {
   global $a, $b;
   $a += 7;
   $a++;
   $b += $a;
   return true;
}
echo $b, $a;                    



Question: 54 (ID:703)

ID: 703


Which of the statements about traits below are true ?





Question: 55 (ID:176)

ID: 176


Which of the following protocols is used for mail transfer?





Question: 56 (ID:787)

ID: 787


What is displayed when the following code is executed?


                        
abstract class A {
    abstract public function f();
}

(new anonymousclass extends A {
    public function f() {
        echo 'Hello World';
    }
})->f();                    



Question: 57 (ID:86)

ID: 86


Which of the following functions will you use to merge one or more arrays?





Question: 58 (ID:473)

ID: 473


Which of the following are true (choose three)?





Question: 59 (ID:214)

ID: 214


All of the following are the advantages of Webservice except for which one?





Question: 60 (ID:235)

ID: 235


Which of the following PCRE expressions is used to match any white space character?





Question: 61 (ID:655)

ID: 655


PHP 5 supports which of the following XML parsing methods?





Question: 62 (ID:103)

ID: 103


What is the result of the following code?


                        
function foo() {
    return array_sum(func_get_args());
}
$x = foo(1,2,3);
echo ($x ?? 'x');                    



Question: 63 (ID:6)

ID: 6


You run the following PHP script:


                        
for($x = 1; $x <= 2; $x++) {
      for($y = 1; $y <= 3; $y++) {
         if ($x == $y) continue; 
         print("x = $x  y =  $y");
      }
}
                    

What will be the output? Each correct answer represents a complete solution. Choose all that apply.



Question: 64 (ID:718)

ID: 718


How do you obtain the length of a string in PHP ?





Question: 65 (ID:690)

ID: 690


What output will this code produce ?


                        
class Disney {
    public $cartoon;
    function __construct($cartoon) {
        $this->cartoon = $cartoon;
    }
}

$disney = new Disney("The Beauty and The Beast");
$waltDisney = $disney;
$waltDisney->cartoon = "Pinocchio";
echo $disney->cartoon;                    



Question: 66 (ID:789)

ID: 789


Give the following expression: "$$foo['bar']". Which of the statements below are true?





Question: 67 (ID:282)

ID: 282


What will be the output of the following PHP code?


                        
array_combine([1,2,3], [4,5,6]);                    



Question: 68 (ID:82)

ID: 82


What will be the output of the following PHP code snippet?


                        
$array = array(1.1 => '1', 1.2 => '1');
echo count($array);                    



Question: 69 (ID:463)

ID: 463


Using the notation self::$property refers to:





Question: 70 (ID:542)

ID: 542


What is the output of the following code?


                        
function oranges(&$oranges = 17) {
    $oranges .= 1;
}
$apples = 5;
oranges($apples);
echo $apples++;                    



Question: 71 (ID:8)

ID: 8


What will be the output of the following PHP script:


                        
function modifyArray(&$array) {
    foreach ($array as &$value) {
        $value = $value + 2;
    }
    $value = $value + 3;
}

$array = array(1, 2, 3);
modifyArray($array);
print_r($array);                    



Question: 72 (ID:197)

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);                    



Question: 73 (ID:561)

ID: 561


Using flock() to lock a stream is only assured to work under what circumstances?





Question: 74 (ID:433)

ID: 433


What is the output of the following line of code:


                        
$a = 4 << 2 + 1;
echo $a;                    



Question: 75 (ID:363)

ID: 363


What PHP function is used to create a new array pre-filled with a sequential series of values?