Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:745)

ID: 745


What is the key difference between HEREDOC and NOWDOC?





Question: 2 (ID:471)

ID: 471


What is the output of the following code?


                        
if(strcmp("hi", "HI")) echo "hello";
elseif(strcasecmp("hi","HI")) echo "world";
else throw new Exception("HI");                    



Question: 3 (ID:450)

ID: 450


What is the output of:


                        
$a = "0";
echo strlen($a);
echo empty($a) ? $a : 5;
echo $a ?: 5;                    



Question: 4 (ID:658)

ID: 658


If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?





Question: 5 (ID:489)

ID: 489


Which object method is automatically called when an object is cloned?





Question: 6 (ID:306)

ID: 306


If you want to read exactly one byte of a file. Which of the following functions will you use to accomplish the task? Each correct answer represents a complete solution. (Choose two)





Question: 7 (ID:793)

ID: 793


What is the result of the following code?


                        
$x = true and false;
$y = (true and false);
var_dump($x);
var_dump($y);                    



Question: 8 (ID:42)

ID: 42


Which of the following functions returns current Unix timestamp?





Question: 9 (ID:107)

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

What will be the output?



Question: 10 (ID:553)

ID: 553


Which functions would be needed to translate the following string:


                        
I love PHP 5
                    

to the following?



Question: 11 (ID:645)

ID: 645


When migrating the following code from PHP 4 to PHP 5, what should be changed?


                        
class MyClass {
    function MyClass($param) {
        # Do something with $param
        $this->_doSomething($param);
    }
    // Private method to MyClass
    function _doSomething($param)  {
        # Do something with $param
    }
}

class AnotherClass extends MyClass {
    var $param = "foo";
    function AnotherClass()  {
        parent::MyClass($this->param);
    }
}                    



Question: 12 (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: 13 (ID:775)

ID: 775


What are the main advantages of replacing many fatal errors with Exceptions in PHP 7?





Question: 14 (ID:637)

ID: 637


What is the output of the following?


                        
$a = 010;
$b = 0xA;
$c = 2;    
print $a + $b + $c;                    



Question: 15 (ID:83)

ID: 83


Which of the following is the correct naming convention of user defined functions?





Question: 16 (ID:363)

ID: 363


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





Question: 17 (ID:47)

ID: 47


What is the length of the hash generated by the crc32() crypto function?





Question: 18 (ID:692)

ID: 692


What is the output of the following script ?


                        
function generate() {
  for ($i = 1; $i <= 3; $i++) {
      yield $i;
  }
}
$generator = generate();
if (is_array($generator)) {
    echo "Is Array";
} elseif(is_object($generator)) {
    echo "Is Object";
} else {
    echo "Is none of the above";
}                    



Question: 19 (ID:578)

ID: 578


When writing portable database code using PDO, what is the PDO::ATTR_CASE attribute useful for?





Question: 20 (ID:88)

ID: 88


You have been given the date format "yyyy-mm-dd". You want to put values in the $year, $month, and $day variables. Which of the following PHP code snippets will you execute to accomplish this task?





Question: 21 (ID:252)

ID: 252


You have a table created as follows:


                        
create table foo (c1 int, c2 char(30), c3 int, c4 char(10))                    

If column c1 is unique, which of the following indexes would optimize the statement given below?



Question: 22 (ID:681)

ID: 681


Consider the following script:


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



Question: 23 (ID:358)

ID: 358


What expression would you pass to error_reporting() if you want all errors and warnings (including "strict" warnings), but not notices (E_NOTICE)?





Question: 24 (ID:399)

ID: 399


What is the output of the following PHP script?


                        
$subs = ['@'  => '<at>',  'com' => 'net'];
$email = "your_name@mail.com";
echo strtr($email, $subs);                    

Enter the exact script output



Question: 25 (ID:30)

ID: 30


Which of the following code can be used to create case insensitive constant?





Question: 26 (ID:715)

ID: 715


What are the possible security implications of printing an unfiltered request variable ?





Question: 27 (ID:652)

ID: 652


What should go in the missing line ????? below to produce the output shown?


                        
$array_one = array(1,2,3,4,5);
$array_two = array('A', 'B', 'C', 'D', 'E');
/* ????? */ 
print_r($array_three);    
/* Result:   
    Array
    (
        [5] => A
        [4] => B
        [3] => C
        [2] => D
        [1] => E
    )
*/                    



Question: 28 (ID:468)

ID: 468


What is the output of the following code?


                        
function format(&$item) {
   $item = strtoupper($item) . '.';
   return $item;
}
$shopping = array("fish", "bread", "eggs", "jelly", "apples");
array_walk($shopping, "format");
$shopping = sort($shopping);
echo $shopping[1];                    



Question: 29 (ID:369)

ID: 369


What is the output of the following code?


                        
$myArray = array();
array_unshift($myArray, 10, 20);
echo $myArray[0];                    



Question: 30 (ID:436)

ID: 436


How many parameters does array_merge() accept?





Question: 31 (ID:555)

ID: 555


Consider the following code:


                        
header("Location: {$_GET['url']}");                    

Which of the following values of $_GET['url'] would cause session fixation?



Question: 32 (ID:51)

ID: 51


Which of the following options shows the correct IF statement format?





Question: 33 (ID:773)

ID: 773


What is the result of the following code?


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



Question: 34 (ID:668)

ID: 668


What are the values of $a in $obj_one and $obj_two when this script is executed?


                        
class myClass {
    private $a;
    public function __construct() {
        $this->a = 10;
    }
    public function printValue() {
        print "{$this->a},";
    }
    public function changeValue($val, $obj = null) {
        if (is_null($obj)) {
            $this->a = $val;
        } else {
            $obj->a = $val;
        }
    }
    public function getValue() {
        return $this->a;
    }
}

$obj_one = new myClass();
$obj_two = new myClass();

$obj_one->changeValue(20, $obj_two);
$obj_two->changeValue($obj_two->getValue(), $obj_one);

$obj_two->printValue();
$obj_one->printValue();                    



Question: 35 (ID:243)

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?



Question: 36 (ID:731)

ID: 731


Which of the following is the best option to iterate and modify every element of an array ?





Question: 37 (ID:709)

ID: 709


How does Opcode Cache improve performance in PHP 5.5+ ?





Question: 38 (ID:264)

ID: 264


You want to make a cookie available only for the HTTP protocol. Which of the following setcookie() parameters would you use to accomplish this?





Question: 39 (ID:39)

ID: 39


Which of the following is/are FALSE regarding OOP in PHP 5.3?





Question: 40 (ID:308)

ID: 308


What is the output of the following PHP script:


                        
$a = 10;
$b = 20;
$c = 30;
echo ($a < 50 && $b > 100 || $c == 30) ? "a" : "b";
echo ($b < 50 XOR $c == 30) ? "c" : "d";                    

Enter the exact script output



Question: 41 (ID:656)

ID: 656


Creating new nodes in XML documents using PHP can be done using which XML/PHP 5 technologies?





Question: 42 (ID:619)

ID: 619


The MVC pattern in Web development involves which of the following components?





Question: 43 (ID:24)

ID: 24


Consider the following code:


                        
$x = 0;
$i;
for($i = 0; $i < 5; $i++) {
    $x += $i;
}
print($x);                    

What will be the value of x?



Question: 44 (ID:451)

ID: 451


What would happen when the following code was run?


                        
define('Tree', 'oak');
echo 'This tree is: ' . tree;                    



Question: 45 (ID:626)

ID: 626


Setting a HTTP cookie on the client which is not URL-encoded is done how in PHP 5?





Question: 46 (ID:33)

ID: 33


You run the following PHP script:


                        
<?php echo 0x33, ' birds sit on ', 022, ' trees.';                    

What will be the output?



Question: 47 (ID:337)

ID: 337


What is the output of the following script?


                        
$x = 5;
$y = $x << 1;
switch ($x + $y) {
    case 5:
        echo "a";
        break;
    case 10:
        echo "b";
        break;
    case 15:
        echo "c";
    case 20:
        echo "d";
        break;
    default:
        echo "e";
}                    



Question: 48 (ID:258)

ID: 258


Which of the following joins will you use to display data that do not have an exact match in the column?





Question: 49 (ID:556)

ID: 556


What is the output of the following script?


                        
function x10(&$number) {
        $number *= 10;
 }    
 $count = 5;
 x10($count);
 echo $count;                    



Question: 50 (ID:607)

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;                    



Question: 51 (ID:449)

ID: 449


Is the following valid PHP code?


                        
<php>
echo 'There's a worm in my apple';
</php>                    



Question: 52 (ID:798)

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



Question: 53 (ID:135)

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



Question: 54 (ID:143)

ID: 143


Consider the following PHP code snippet:


                        
class Object
{
   function Object($entity) {
       $entity->name = "John";
   }
}
class Entity
{
     public $name = "Maria";
}
$entity = new Entity();
$obj = new Object($entity);
print $entity->name;                    

What should be the output of this script (Ignore warning)?



Question: 55 (ID:792)

ID: 792


What is the result of the following code?


                        
var_dump(1 < 2 > 1);
                    



Question: 56 (ID:25)

ID: 25


Consider the following code:


                        
$a = 20;
$b = 4;
$c = $a % $b;
print($c);                    

What will be the value of the variable c?



Question: 57 (ID:663)

ID: 663


What is the best way to ensure that a user-defined function is always passed an object as its single parameter?





Question: 58 (ID:221)

ID: 221


You run the following PHP script:


                        
if ( preg_match("/[^a-z589]+/", "AB asdfg589nmGH", $array) )  {
    print "<pre>\n";
    print_r( $array );
    print "</pre>\n";
}                    

What will be the output?



Question: 59 (ID:562)

ID: 562


To destroy a PHP session completely, one must which of the following?





Question: 60 (ID:147)

ID: 147


Which of the following modes of the fopen() function opens a file in read and write mode and creates one if it does not exist?





Question: 61 (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: 62 (ID:758)

ID: 758


What is the relationship between classes and objects?





Question: 63 (ID:445)

ID: 445


Which of the following functions would be a valid way to create an array containing items from three existing arrays?





Question: 64 (ID:454)

ID: 454


What will the output of the following code be?


                        
$a = range(3,9);
foreach ($a as $b) {
   switch($b) {
      case 3:
      $b = 7;
      case 7:
      $b = 3;
      default:
      // do nothing
   }
}

echo implode('-',$a);                    



Question: 65 (ID:462)

ID: 462


ArrayAccess is an example of a:





Question: 66 (ID:294)

ID: 294


Consider the following PHP script:


                        
 $fp = fopen('file.txt', 'r');
 $string1 = fgets($fp, 512);
 fseek($fp, 0);                    

Which of the following functions will give the same output as that given by the fseek() function in the above script?



Question: 67 (ID:144)

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?





Question: 68 (ID:501)

ID: 501


What is the output of this script the third time it is loaded in a browser by the same user?


                        
session_start();
if (!array_key_exists('counter', $_SESSION)) {
    $_SESSION['counter'] = 0;
} else {
    $_SESSION['counter']++;
}
session_regenerate_id();
echo $_SESSION['counter'];                    



Question: 69 (ID:428)

ID: 428


Which of the following statements best describes how number_format() works?





Question: 70 (ID:273)

ID: 273


The dl() function is used to load PHP extensions on the server at runtime. However, you want to disable it due to some security issue. Which of the following actions will you perform to accomplish the task?





Question: 71 (ID:791)

ID: 791


How does the combined comparison operator ("<=>") work when comparing strings?





Question: 72 (ID:473)

ID: 473


Which of the following are true (choose three)?





Question: 73 (ID:463)

ID: 463


Using the notation self::$property refers to:





Question: 74 (ID:725)

ID: 725


What happens when you run the script below ?


                        
define("2MYCONSTANT", "avalue");
if(defined("2MYCONSTANT"))
echo "We have a constant: " . 2MYCONSTANT;                    



Question: 75 (ID:716)

ID: 716


What is wrong in the following code (assume that $db is an instance of mysqli, mytable exists and has a column called student):


                        
$sql = "SELECT student FROM mytable WHERE student = '$_POST["student"]'";
if ($result = $db->query($sql)) {
    while($row = $result->fetch_object())
        echo $row->student;
}