Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:746)

ID: 746


What is the output of the following code?


                        
$a  = array(1, 2, 3);
foreach( $a as $x) {
    $x *= 2
}
echo $a[0] * $a[1] * $a[2];                    



Question: 2 (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: 3 (ID:702)

ID: 702


What is the output of the code below ?


                        
$a = ['one'=>'php', 'two'=>'javascript', 'three'=>'python'];
$b = ['python', 'javascript', 'php'];
echo (array_values(array_reverse($a)) === $b) ? 'true' : 'false';                    



Question: 4 (ID:603)

ID: 603


Which of the following is the best way to split a string on the "-=-" pattern?


                        
$string = 'apple-=-banana-=-orange';                    



Question: 5 (ID:581)

ID: 581


To destroy one variable within a PHP session you should use which method in PHP 5?





Question: 6 (ID:122)

ID: 122


Which of the following error constants gives all errors and warnings, except the E_STRICT error level?





Question: 7 (ID:180)

ID: 180


Which of the following is a PHP script vulnerability of the mail() function that can occur in Internet applications that are used to send email messages?





Question: 8 (ID:59)

ID: 59


You run the following PHP script:


                        
<php echo (int) "Jason 1235"; 
                    

What will be the output?



Question: 9 (ID:303)

ID: 303


Which of the following functions will you use to change the number of bytes to buffer?





Question: 10 (ID:11)

ID: 11


What does the following function do, when passed two integer values for $p and $q?


                        
function magic($p, $q) {  
     return ($q == 0) ? $p : magic($q, $p % $q);
}                    



Question: 11 (ID:695)

ID: 695


What happens when the script below is executed ?


                        
namespace CustomArea;
error_reporting(E_ALL);
ini_set("display_errors", "on");
function var_dump($a) {
  return str_replace("Weird", $a, "Weird stuff can happen");
}
$a = "In programming";
echo var_dump($a);                    



Question: 12 (ID:177)

ID: 177


Which of the following directives should you delete to secure your applications? Each correct answer represents a complete solution. (Choose all that apply)





Question: 13 (ID:348)

ID: 348


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





Question: 14 (ID:763)

ID: 763


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





Question: 15 (ID:708)

ID: 708


What is the best way to store and verify passwords in PHP ?





Question: 16 (ID:291)

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.





Question: 17 (ID:548)

ID: 548


Which of the following extensions are no longer part of PHP 5 and have been moved to PECL?





Question: 18 (ID:398)

ID: 398


What is the output of the following PHP script?


                        
$values = array(37, 5, "09");
sort($values, SORT_STRING);
foreach ($values as $v) {
    echo $v;
}                    



Question: 19 (ID:333)

ID: 333


What is the output of the following PHP script?


                        
define('SOMEVAL', 0);
if (strlen(SOMEVAL) > 0) {
    echo "Hello";
} else {
    echo "Goodbye";
}                    



Question: 20 (ID:459)

ID: 459


Which of the following statements are true when applied to a Registry pattern? (choose two)





Question: 21 (ID:171)

ID: 171


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





Question: 22 (ID:707)

ID: 707


Which of the following statements about object serialization are true ?





Question: 23 (ID:742)

ID: 742


What is the output of the following code?


                        
$str = 'abcdef';
if (strpos($str, 'a')) {
    echo "Found the letter 'a'";
} else {
    echo "Could not find the letter 'a'";
}                    



Question: 24 (ID:54)

ID: 54


Which of the following is NOT a strongly typed language?





Question: 25 (ID:10)

ID: 10


Which one of the following four logical operators of PHP is not binary?





Question: 26 (ID:594)

ID: 594


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





Question: 27 (ID:381)

ID: 381


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





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

ID: 519


When opening a file in writing mode using the FTP handler, what must be done so that the file will still be written to the server in the event it previously exists?





Question: 31 (ID:739)

ID: 739


What is goog rule to follow when quoting string data?





Question: 32 (ID:558)

ID: 558


Consider the following code block:


                        
function &myFunction() {
    $string = "MyString";
    var_dump($string);

    return ($undefined);
}
for ($i = 0; $i < 10; $i++) {
    $retval = myFunction();
}                    

This code block's behavior has changed between PHP 4 and PHP 5. Why?



Question: 33 (ID:351)

ID: 351


What is the output of the following PHP script?


                        
$i = ord('a');
do {
    echo chr($i);
} while ($i++ < ord('f') + 1);                    

Enter the exact script output



Question: 34 (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: 35 (ID:376)

ID: 376


Which function is used to return true if a given value exists in an array (and false if it doesn't)?





Question: 36 (ID:280)

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>                    



Question: 37 (ID:477)

ID: 477


Which of the following php configuration directives were deprecated in PHP 5.3 (tick as many as apply)?





Question: 38 (ID:537)

ID: 537


Which of the following comparisons will evaluate to true?


                        
var_dump(
    't' == t, // Notice
    1 === "1time",
    "top" == 0,
    "top" === 0,
    1 == "1time"
);                    



Question: 39 (ID:492)

ID: 492


Given a class called SoapFunctions and a working WSDL for the methods in that class, what needs to be added to the code below to serve those methods over SOAP?


                        
require("SoapFunctions.php");
$s = new SoapServer($wsdl);
$s->handle();                    



Question: 40 (ID:323)

ID: 323


What is the output of the following PHP (PHP7) script?


                        
$string1 = 'foo' . 'bar';
$string2 = 'hello' + 'goodbye';
$string3 = "abc" + "123";

echo sprintf('%s - %s - %s', $string1, $string2, $string3);                    

Enter the exact script output



Question: 41 (ID:589)

ID: 589


What combination of boolean values for $a, $b, $c, and $d will result in the variable $number being equal to 3?


                        
$a = null;
$b = null;
$c = null;
$d = null;

if($a && !$b) {
    if(!!$c && !$d) {
        if($d && ($a || $c)) {
            if(!$d && $b) {
                $number = 1;
            } else {
                $number = 2;
            }
        } else {
            $number = 3;
        }
    } else {
        $number = 4;
    }
} else {
    $number = 5;
}                    



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

ID: 451


What would happen when the following code was run?


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



Question: 44 (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: 45 (ID:191)

ID: 191


Which of the following protocols is normally used by Webservices?





Question: 46 (ID:577)

ID: 577


Type-hinting and the instanceof keyword can be used to check what types of things about variables?





Question: 47 (ID:200)

ID: 200


Which of the following functions returns an XML string based on SimpleXML element?





Question: 48 (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: 49 (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: 50 (ID:761)

ID: 761


Which of the following statements about static functions is true?





Question: 51 (ID:754)

ID: 754


What is the output of the following code? (May be multiple answers)


                        
function addValues() {
    $sum = 0;
    for ($i = 0; $i <= func_num_args(); $i++) {
        $sum += func_get_arg($i);
    }
    return $sum;
}
echo addValues(1,2,3);                    



Question: 52 (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: 53 (ID:283)

ID: 283


You have the following code in the welcome.html file:


                        
<form action="welcome.php" method="post">
    Your Name: <input type="text" name="fname" />
    Your Girl Friend Name: <input type="text" name="fname" />
    <input type="submit" />
</form>                    

The PHP code of the welcome.php file is as follows:



Question: 54 (ID:159)

ID: 159


You want to stop showing PHP errors or to show only critical errors so that a malicious hacker cannot hack your Website. Which of the following PHP directive settings will you use to accomplish this task? Each correct answer represents a part of the solution. Choose all that apply.





Question: 55 (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: 56 (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: 57 (ID:328)

ID: 328


Of the following options, which are valid variable names?





Question: 58 (ID:743)

ID: 743


What will this code do?


                        
$var = 2;
$str = 'aabbccddeeaabbccdd';
echo str_replace('a', 'z', $str, $var);                    



Question: 59 (ID:429)

ID: 429


Given the following PHP code, what value must be assigned to $format so each digit is extracted individually in the call to sscanf()?


                        
$str = '31337';
$format = '???';
$digits = sscanf($str, $format);
var_dump($digits);                    



Question: 60 (ID:653)

ID: 653


What is the output of the following code?


                        
function byReference(&$variable = 0){
    echo ++$variable;
}    
byReference();
byReference();                    



Question: 61 (ID:265)

ID: 265


Which of the following HTML code snippets can be used for the file uploading?





Question: 62 (ID:442)

ID: 442


What does status code 403 indicate?





Question: 63 (ID:643)

ID: 643


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





Question: 64 (ID:309)

ID: 309


What is the output of the following PHP script:


                        
$a = 0;
if ($a = 10) {
    echo "a";
}
if ($a == 0) {
    echo "b";
}
if ($a == "0") {
    echo "c";
}                    

Enter the exact script output



Question: 65 (ID:647)

ID: 647


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





Question: 66 (ID:452)

ID: 452


Which of the following are valid constant names? (Choose three)





Question: 67 (ID:420)

ID: 420


One way to compare strings in PHP is by using the strcmp() function. This is useful since not only can you determine if two strings are equal, but you can also test if one string is 'greater than' the other (using the corresponding ASCII values in each character comparison). What is the output of the following PHP script?


                        
$test1 = strcmp('hello', "hello");
$test2 = strcmp("Hello", "hello");
$test3 = strcmp('60', '500');

if ($test1 == 0)     { echo "a"; }
else if ($test1 < 0) { echo "b"; }
else                 { echo "c"; }

if ($test2 == 0)     { echo "d"; }
else if ($test2 < 0) { echo "e"; }
else                 { echo "f"; }

if ($test3 == 0)     { echo "g"; }
else if ($test3 < 0) { echo "h"; }
else                 { echo "i"; }                    

Enter the exact script output



Question: 68 (ID:237)

ID: 237


Consider the following PHP code:


                        
<?= strlen(md5(rand(),TRUE));                    



Question: 69 (ID:331)

ID: 331


How do you check if a constant called DEBUG_LEVEL exists in your PHP code?





Question: 70 (ID:149)

ID: 149


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





Question: 71 (ID:744)

ID: 744


What is the output of the following code?


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



Question: 72 (ID:110)

ID: 110


You have given the following PHP code:


                        
class Example {
    public $public = '1';
    private $prv   = '2';
    protected $prt = '3';
}
$arrayobj = new ArrayObject(new Example());
var_dump($arrayobj->count());                    

What will be the output?



Question: 73 (ID:199)

ID: 199


Which of the following was not a built-in terminology before PHP5?





Question: 74 (ID:580)

ID: 580


What does the following code print?


                        
echo 2 <=> 1;                    



Question: 75 (ID:137)

ID: 137


Which of the following SPL Interfaces/classes extends the standard Iterator interface and enables the ability to retrieve a specific item from the internal data store?