Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:684)

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>                    



Question: 2 (ID:209)

ID: 209


All variables in PHP start with which symbol?





Question: 3 (ID:543)

ID: 543


Which of the following is not a valid default stream wrapper for PHP 5, assuming OpenSSL is enabled?





Question: 4 (ID:744)

ID: 744


What is the output of the following code?


                        
$str = printf('%.1f', 7.1);
echo 'Zend PHP Certification ';
echo $str;                    



Question: 5 (ID:466)

ID: 466


What does the html_errors configuration directive do?





Question: 6 (ID:149)

ID: 149


Which of the following functions will you use as a countermeasure against a SQL injection attack?





Question: 7 (ID:406)

ID: 406


What is the output of the following PHP script?


                        
$str = 'stingers';
echo strtr($str, 'st', 'bl');                    

Enter the exact script output



Question: 8 (ID:278)

ID: 278


Consider the following PHP code snippet:


                        
<form method=get>
    <select name ="fruits" id="fruits">
        <option value="1">Apple</option>
        <option>Orange</option>
        <option value="3">Strawberry</option>
    </select>
 <input type="submit" value="Submit">
 <?= $_GET['fruits'] ?? ''; ?>                    

What will be the output if you select 'Orange' from the dropdown menu?



Question: 9 (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: 10 (ID:637)

ID: 637


What is the output of the following?


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



Question: 11 (ID:185)

ID: 185


Fill in the Blank with the appropriate method name. The ___ is used to import the SimpleXML objects for use with DOM. *Exact matching is required.





Question: 12 (ID:650)

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?



Question: 13 (ID:217)

ID: 217


Consider the following script:


                        
$string1 = "ab";
$string2 = "cd";
$string1 = $string1 . $string2; 
$string3 = "abc";
$string1 .= $string3;
echo $string1;                    

What will be the output of the above PHP script?



Question: 14 (ID:405)

ID: 405


What is the output of the following script?


                        
$name = 'Judy';
$str1 = <<<EOF
Hello $name
EOF;
$str2 = <<<'EOF'
Goodbye $name;
EOF;

if (strpos($str1, $name) === false) {
     echo 'a';
} else {
     echo 'b';
}

if (strpos($str2, $name) === false) {
     echo 'c';
} else {
     echo 'd';
}                    



Question: 15 (ID:546)

ID: 546


What is the output of the following?


                        
function a($number) {
    return (b($number) * $number);
}
function b(&$number) {
    return ++$number;
}
echo a(5);                    



Question: 16 (ID:584)

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



Question: 17 (ID:343)

ID: 343


What is the output of the following PHP script?


                        
$myArray = array('a', 'b', 'c');
foreach ($myArray as $k => $v) {
    echo $v;
    for ($i = 1; $i < 5; $i++) {
        if ($i == $k) {
            break(2);
        }
        echo $i;
    }
}                    

Enter the exact script output



Question: 18 (ID:533)

ID: 533


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: 19 (ID:437)

ID: 437


What would you expect to get from PDOStatement::fetch() in its default mode?





Question: 20 (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: 21 (ID:38)

ID: 38


Which of the following PHP variable names is not a valid variable name?





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

ID: 314


What is the output of the following PHP script?


                        
$a = ($b = 13) - 5;
echo $a . ' - ' . $b;                    



Question: 24 (ID:618)

ID: 618


What is the output of the following?


                        
function _1dotEach($n) {
    if ($n > 0) {
        _1dotEach(--$n);
        echo ".";
    } else {
        return $n;
    }
}
_1dotEach(4);                    



Question: 25 (ID:295)

ID: 295


What does the second parameter of the file_get_contents() function do?





Question: 26 (ID:158)

ID: 158


Which of the following are the countermeasures of the remote code injection? Each correct answer represents a complete solution. Choose all that apply.





Question: 27 (ID:348)

ID: 348


What is the difference between including a script with include() and require()?





Question: 28 (ID:547)

ID: 547


What is the output of the following?


                        
function a(&$apples) {
    $apples++;
}
$oranges = 5;
$apples = 5;
a($oranges);
echo "I have $apples apples and $oranges oranges";                    



Question: 29 (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: 30 (ID:534)

ID: 534


When is it acceptable to store sensitive information in an HTTP cookie?





Question: 31 (ID:481)

ID: 481


What does the chr() function do?





Question: 32 (ID:335)

ID: 335


What is the output of the following script?


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



Question: 33 (ID:97)

ID: 97


Which of the following statements will return the second parameter passed to a function?





Question: 34 (ID:334)

ID: 334


What is the output of the following PHP script?


                        
define('MYCONSTANT', 0);
if (empty(MYCONSTANT)) {
    echo "Hello";
} else {
    echo "Goodbye";
}                    



Question: 35 (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: 36 (ID:142)

ID: 142


Fill in the blank with the appropriate word. The ____ operator lets a programmer inspect all of the ancestor classes of the object, as well as any interfaces.





Question: 37 (ID:588)

ID: 588


The __ keyword is used to indicate an incomplete class or method, which must be further extended and/or implemented in order to be used.





Question: 38 (ID:498)

ID: 498


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





Question: 39 (ID:372)

ID: 372


What is the primary difference between array_key_exists() and isset() when checking to see if a given array element exists?





Question: 40 (ID:204)

ID: 204


Fill in the blank with the appropriate function name. The ___ function is used to decode a json encoded string/array.





Question: 41 (ID:141)

ID: 141


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





Question: 42 (ID:225)

ID: 225


Consider the following string:


                        
ZeNd php                    

After running a PHP script, the above string is converted in the following format:



Question: 43 (ID:129)

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



Question: 44 (ID:418)

ID: 418


Using nl2br() is a handy way to format plain-text for output in a HTML document. What is the output of the following PHP script?


                        
$str = nl2br("foo\nbar");

# nl2br doesn't remove the \n
$str = str_replace("\n", "", $str);

echo nl2br($str);                    

Enter the exact script output



Question: 45 (ID:635)

ID: 635


When executing system commands from PHP, what should one do to keep applications secure?





Question: 46 (ID:269)

ID: 269


Which of the following code snippets will you use to redirect your users from one page to another?





Question: 47 (ID:313)

ID: 313


What is output of the following PHP script?


                        
$str = 'foo';
$str .= 'bar';
$num = 0;
$num += 25;
$num -= 15;
echo $str . ' - ' . $num;                    



Question: 48 (ID:403)

ID: 403


What is the key difference between Heredoc and Nowdoc syntax?





Question: 49 (ID:411)

ID: 411


What is the output of the following script?


                        
$html = '<p>line1line2</p>';
echo strip_tags($html, 'br');                    

Enter the exact script output



Question: 50 (ID:604)

ID: 604


What is the output of the following code?


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



Question: 51 (ID:617)

ID: 617


When writing CLI scripts it is often useful to access the standard streams available to the operating system such as standard input/output and error. How does one access these streams in PHP 5/7?





Question: 52 (ID:138)

ID: 138


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





Question: 53 (ID:379)

ID: 379


In the following code, what are the values required in $a, $b, $c and $d to output 40?


                        
$values = array(
    array(
        1 => 10,
        20,
        array(30, array(40))
    ),
    array(
        2 => 50,
        array(
            array(1 => 60, 0 => 70)
        )
    )
);

echo $values[$a][$b][$c][$d];                    



Question: 54 (ID:239)

ID: 239


Consider the following PHP script:


                        
$charlist = [
    'a' => 'one', 
    'b' => 'two', 
]; 
// *****                    

What statement will you write at line number 5 instead of ***** to get the output onectwo?



Question: 55 (ID:230)

ID: 230


Consider the following array:


                        
$arr = ['apple', 'banana', 'cherry'];                    

Which function would you use to get the following string?



Question: 56 (ID:171)

ID: 171


Which of the following functions wraps a string to a given number of characters?





Question: 57 (ID:168)

ID: 168


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



"!dlrow olleH"



Question: 58 (ID:37)

ID: 37


What is the output of the following code snippet?


                        
$a = 20;
function myfunction($b) {
    $a = 30;
    global $a, $c;
    return $c = ($b + $a);
}
print myfunction(40) + $c;                    



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

ID: 56


You run the following PHP script:


                        
$a = 20 % -8;
echo $a;                    



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

ID: 4


What will be the output when you try to run the script below?


                        
$b = false;
if ($b = true) {
  print("true");
} else {
  print("false");
}                    



Question: 64 (ID:571)

ID: 571


When working with SimpleXML in PHP 5, the four basic rules on how the XML document is accessed are which of the following?





Question: 65 (ID:54)

ID: 54


Which of the following is NOT a strongly typed language?





Question: 66 (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: 67 (ID:380)

ID: 380


How do you remove an element with the key 0 from the array $numbers?





Question: 68 (ID:611)

ID: 611


Which of the following functions could be used to break a string into an array?





Question: 69 (ID:509)

ID: 509


Which of the following is not a valid fopen() access mode:





Question: 70 (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: 71 (ID:693)

ID: 693


What is the default value for the "max_execution_time" setting when running PHP as a CLI SAPI ?





Question: 72 (ID:728)

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 ?





Question: 73 (ID:90)

ID: 90


Consider the following PHP script:


                        
$a = 5;
$b = 10;
function Mul() {
    $GLOBALS['b'] = $GLOBALS['a'] * $GLOBALS['b'];
}
Mul();
print($b);                    

What will be the output?



Question: 74 (ID:688)

ID: 688


Why is it important from a security perspective to never display PHP error messages directly to the end user, yet always log them?





Question: 75 (ID:579)

ID: 579


What does the following code print?


                        
$a = 'aaaa';
$b = 'bbbb';
echo $a ?? $b ?? 'cccc';