Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:670)

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?





Question: 2 (ID:216)

ID: 216


Which of the following is used to create an XML parser with namespace support?





Question: 3 (ID:585)

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?



Question: 4 (ID:259)

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?





Question: 5 (ID:766)

ID: 766


Which is the correct syntax to define a class constant for the class MyClass?





Question: 6 (ID:791)

ID: 791


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





Question: 7 (ID:487)

ID: 487


What is the output of the following code?


                        
function swings(&$park) {
   $park++;
   $park = roundabout($park);
}
function roundabout($park) {
   $park *= 2;
}

$park = 17;
echo swings($park);                    



Question: 8 (ID:765)

ID: 765


Of the following statements about typehints, which is NOT true?





Question: 9 (ID:282)

ID: 282


What will be the output of the following PHP code?


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



Question: 10 (ID:125)

ID: 125


Which of the following methods is called when a user sets a value of an undeclared or undefined attribute of a class?





Question: 11 (ID:61)

ID: 61


Which of the following functions allows you to stack several error handlers on top of each other?





Question: 12 (ID:461)

ID: 461


What is the output of this code?


                        
$wish_list = array(
   1 => "Romeo and Juliet",
   4 => "Bad Science",
   2 => "To Kill A Mockingbird"
);
print_r(sort($wish_list));                    



Question: 13 (ID:516)

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 ?



Question: 14 (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: 15 (ID:9)

ID: 9


Which of the below provided options is correct regarding the below code?


                        
$a = array(1, 2, 3);
$b = array(1=> 2, 2 => 3, 0 => 1);
$c = array('a' => 1,'b' => 2,'c' => 3);
var_dump($a == $b);
var_dump($a === $b);
var_dump($a == $c);                    



Question: 16 (ID:341)

ID: 341


What is the output of the following PHP script?


                        
for ($i = 5; ; $i++) {
    if ($i < 10) {
        break;
    }
}
echo $i;                    

Enter the exact script output



Question: 17 (ID:563)

ID: 563


What is the output of the following code block?


                        
$a = "The quick brown fox jumped over the lazy dog.";
$b = array_map("strtoupper", explode(" ", $a));

foreach ($b as $value) {
    print "$value ";
}                    



Question: 18 (ID:5)

ID: 5


Which of the following options is/are correct regarding variable scopes in PHP?





Question: 19 (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: 20 (ID:659)

ID: 659


Which function would you use to add an element to the beginning of an array?





Question: 21 (ID:703)

ID: 703


Which of the statements about traits below are true ?





Question: 22 (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: 23 (ID:130)

ID: 130


You run the following PHP script:


                        
class number 
{
    public $a = 1;
    protected $b = 2;
    private $c = 3;
}
$numbers = new number();
foreach($numbers as $value) {
    echo "$value ";
}                    

What will be the output?



Question: 24 (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: 25 (ID:586)

ID: 586


What variable reference would go in the spots indcated by ????? in the code segment below?


                        
$msg = "The Quick Brown Foxed Jumped Over the Lazy Dog";
$state = true;
$retval = "";
for ($i = 0; (isset(?????)); $i++) {
if ($state) {
    $retval .= strtolower(?????);
} else {
    $retval .= strtoupper(?????);
}
$state = !$state;
}

print $retval;                    



Question: 26 (ID:30)

ID: 30


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





Question: 27 (ID:296)

ID: 296


Which of the following functions is used to delete a file?





Question: 28 (ID:161)

ID: 161


Consider the following PHP script:


                        
<?= "Welcome, {$_POST['name']}.";                     

What type of attack is possible with this PHP script?



Question: 29 (ID:423)

ID: 423


What is the output of the following PHP script?


                        
$a = 0.5;
$b = 0.1;
$c = 16;
echo sprintf('%01.2lf %.1lf 0x%x', $a, $b, $c);                    



Question: 30 (ID:257)

ID: 257


Which of the following joins retrieves all rows from one table and only the matching rows from the joined table?





Question: 31 (ID:467)

ID: 467


What is the output of the following code?


                        
$a = 1;
function calculate() {
   global $a;
   $a += 7;
   $a = $a * 043;
   return --$a;
}
echo $a;                    



Question: 32 (ID:489)

ID: 489


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





Question: 33 (ID:686)

ID: 686


When embedding PHP into XML documents, what must you ensure is true in order for things to function properly?





Question: 34 (ID:100)

ID: 100


Consider the following script:


                        
$a = array('a', 'b'); 
array_push($a, array(1, 2)); 
print_r($a);                    

What will be the output?



Question: 35 (ID:498)

ID: 498


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





Question: 36 (ID:578)

ID: 578


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





Question: 37 (ID:698)

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 ?



Question: 38 (ID:711)

ID: 711


Which is a valid way for calling test function?


                        
function test(?int $n) {
    var_dump($n);
}                    



Question: 39 (ID:300)

ID: 300


Fill in the blank with the appropriate PHP function. The ___ function generates a file resource having 0600 file permission in the file system with a randomly-generated filename to be used as temporary storage. *Exact matching is required.





Question: 40 (ID:381)

ID: 381


How do you create an array called $arr consisting of a single element with the value 15?





Question: 41 (ID:373)

ID: 373


What function is used to remove and return the first element of an array?





Question: 42 (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: 43 (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: 44 (ID:488)

ID: 488


What is the output of the following code?


                        
function print_conditional($x) {
   if ($x++ == 1) echo "none";
   echo "one";
   echo "none";
   return $x;
}
$x = 1;
print_conditional($x);
$x++;
print_conditional($x);                    



Question: 45 (ID:173)

ID: 173


Which of the following functions can be used to translate characters or replace substrings?





Question: 46 (ID:163)

ID: 163


Consider a scenario in which a website allows users to upload pictures. What kind of security should be set to prevent attacks?





Question: 47 (ID:138)

ID: 138


Which of the following is triggered when inaccessible methods are triggered in an object context?





Question: 48 (ID:773)

ID: 773


What is the result of the following code?


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



Question: 49 (ID:73)

ID: 73


Consider the following PHP script:


                        
$base_array = array("red", "green", "yellow", "white");
$replacements_array = array(0 => "orange", 4 => "blue");
$result = array_replace($base_array, $replacements_array);
print_r($result);                    

What will be the output of the script?



Question: 50 (ID:660)

ID: 660


What is the output of the following?


                        
function l(&$number) {
    $number *= 10;
    return ($number - 5);
}    
$number = 10;
$number = L($number);
echo $number;                    



Question: 51 (ID:215)

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.





Question: 52 (ID:775)

ID: 775


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





Question: 53 (ID:3)

ID: 3


Consider the following code:


                        
$a = 5;
$b = 12;
$c = 10;
$d = 7;
$e = ($a * $b) + $c * $d / $a;
print($e);                    

What will be the output of the above code?



Question: 54 (ID:805)

ID: 805


What is displayed when the following code is executed?


                        
$a = ['a' => 20, 1 => 36, 40];
array_rand($a);
echo $a[0];                    



Question: 55 (ID:356)

ID: 356


Is the following code valid, or will it cause a syntax error? Note the missing semi-colon at the end of the statement.


                        
<?= "Hello" ?>                    



Question: 56 (ID:179)

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)





Question: 57 (ID:17)

ID: 17


Which of the following types of errors halts the execution of a script and cannot be trapped?





Question: 58 (ID:184)

ID: 184


What will be the output of the following PHP script?


                        
$dom = new DOMDocument();
$dom->load('book.xml');
$a = $dom->documentElement;
print_r($a);                    



Question: 59 (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: 60 (ID:335)

ID: 335


What is the output of the following script?


                        
$number = 100;
echo $number < 10 ? "a" : ($number > 100 ? "b" : "c");                    



Question: 61 (ID:148)

ID: 148


Which of the following PHP functions will you use as a countermeasure against a cross-site scripting (XSS) attack?





Question: 62 (ID:168)

ID: 168


Which of the following functions will you use to get the following output of string "Hello world!"?



"!dlrow olleH"



Question: 63 (ID:601)

ID: 601


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





Question: 64 (ID:330)

ID: 330


How do you check if a variable $name exists in the current scope in a PHP script?





Question: 65 (ID:616)

ID: 616


If you would like to store your session in the database, you would do which of the following?





Question: 66 (ID:203)

ID: 203


Which of the following functions will you use to create a new DomElement node? Each correct answer represents a complete solution. Choose three.




  • [ ] C)

    DomDocument::createElementNS()

Question: 67 (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: 68 (ID:564)

ID: 564


What does the following code will print in PHP 7?


                        
$a = [0, 1, 2];
foreach($a as $val) {
    var_dump(current($a));
}                    



Question: 69 (ID:76)

ID: 76


Which of the following functions is used to insert a new element in the beginning of an array?





Question: 70 (ID:574)

ID: 574


Which of the following list of potential data sources should be considered trusted?





Question: 71 (ID:81)

ID: 81


What will be the output of the following code snippet?


                        
$array = array(1 => 'one', 3 => '10');
echo $array;                    



Question: 72 (ID:593)

ID: 593


Which of the following are valid PHP variables? (Choose 3)





Question: 73 (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: 74 (ID:28)

ID: 28


You run the following PHP script:


                        
$x = 10;
$b = ++$x;
print($b);                    

What will be the value of the variable $b?



Question: 75 (ID:397)

ID: 397


Consider the following PHP code, which defines an associative array of fruits and vegetables.


                        
$fruitAndVeg = array(
        'c' => 'Carrot',
        'p' => 'Tomato',
        'b' => 'Banana',
        't' => 'Potato',
        'a' => 'Apple'
);

/** line **/

$keys = array_keys($fruitAndVeg);
echo $keys[0];                    

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