Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (ID:459)

ID: 459


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





Question: 2 (ID:150)

ID: 150


Which function escapes all of the shell metacharacters and control operators within a string?





Question: 3 (ID:69)

ID: 69


Consider the following PHP script:


                        
$a = [
    '1' => "php",
    "Hypertext",
    "Preprocessor",
    "widely used" => [
        'general' => 'purpose',
        'scripting' => 'language',
        'that' => 'was',
        'originally' => [
            5 => 'designed',
            9 => 'for',
            'Web development',
            4 => 'purpose'
        ]
    ]
];
//write code here                      

What should you write here to print the value 'Web development'?



Question: 4 (ID:145)

ID: 145


Fill in the blank with the appropriate method. The ____ method automatically calls whenever a user tries to instantiate a nonexistent class.





Question: 5 (ID:87)

ID: 87


You want to create an anonymous function in the middle of a script that will return the square of a given number. Which of the following PHP scripts can you use to accomplish the task?



Each correct answer represents a complete solution. (Choose two)



Question: 6 (ID:640)

ID: 640


What is the output of the following?


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



Question: 7 (ID:646)

ID: 646


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





Question: 8 (ID:86)

ID: 86


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





Question: 9 (ID:164)

ID: 164


Which of the following functions is the best choice to retrieve the fingerprint of a string?





Question: 10 (ID:477)

ID: 477


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





Question: 11 (ID:220)

ID: 220


What will be the output of the following code?


                        
$s = '13149';
$s[$s[1]] = $s[1]+$s[3];
print_r($s);                    



Question: 12 (ID:93)

ID: 93


Which of the following functions can be used to check whether a particular element exists in a given array or not?





Question: 13 (ID:503)

ID: 503


Which of the following statements best describes session fixation?





Question: 14 (ID:76)

ID: 76


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





Question: 15 (ID:486)

ID: 486


What does the following code output?


                        
$i = function($j) {
   $i = $j + 4;
   return $i++;
};
$j = 6;
echo $i($j);                    



Question: 16 (ID:153)

ID: 153


John works as a professional ethical hacker. He has been assigned the project of testing the security of www.we-are-secure.com. On the We-are-secure login page, he enters ='or''=' as a username and successfully logs in to the user page of the Web site. To which of the following attacks is the We-are-secure login page vulnerable?





Question: 17 (ID:628)

ID: 628


Which of the following SQL statements will improve SQLite write performance?





Question: 18 (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: 19 (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: 20 (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: 21 (ID:789)

ID: 789


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





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

ID: 32


Consider the following PHP script:


                        
function b($a = 4) {
    $a = $a / 2;
    return $a;
}

$a = 10;
b($a);
echo $a;                    

What will be the output?



Question: 24 (ID:762)

ID: 762


Which of the following statements about autoloading is true?





Question: 25 (ID:251)

ID: 251


Martin works as a Database Administrator for MTech Inc. He designs a database that has a table named Products. He wants to create a report listing different product categories. He does not want to display any duplicate row in the report. Which of the following SELECT statements will Martin use to create the report?





Question: 26 (ID:380)

ID: 380


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





Question: 27 (ID:579)

ID: 579


What does the following code print?


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



Question: 28 (ID:45)

ID: 45


You run the following PHP script:


                        
$a = 12;
$b = 11;   
$a > $b ? print($a) : print($b);                    



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

ID: 425


What value should be assigned to $format to ensure the following script outputs 250007? It must use the d formatter.


                        
$number1 = 250;
$number2 = 7;
$format = '???';
echo sprintf($format, $number1);
echo sprintf($format, $number2);
// output is 250007                    

Do not include quotes



Question: 31 (ID:198)

ID: 198


Which of the following is an XML protocol that implements the communication between one to another machine, including the publishing, finding, binding, and calling of a Webservice?





Question: 32 (ID:293)

ID: 293


Which of the following statements is true about __FILE__ constant?





Question: 33 (ID:513)

ID: 513


Which of the following functions are used with the internal array pointer to accomplish an action?





Question: 34 (ID:595)

ID: 595


Setting a cookie on the client in PHP 5 can be best accomplished by:





Question: 35 (ID:35)

ID: 35


In which of the following ways does the identity operator === compare two values?





Question: 36 (ID:383)

ID: 383


In the following code, what is the key of the element with value 25?


                        
$myArray = ['foo' => 'bar',  7 => 15,  28];
$myArray[] = 25;                    



Question: 37 (ID:192)

ID: 192


Which of the following functions can you use to add data? Each correct answer represents a complete solution. Choose all that apply.





Question: 38 (ID:146)

ID: 146


Consider the following PHP script:


                        
$a = 5; 
$b = 4; 
$c = ($a++ * ++$b);  
echo $c;                    

What will be the output?



Question: 39 (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: 40 (ID:417)

ID: 417


What is the output of the following script?


                        
$str = 'abcd';
echo substr($str, 0, 1);
echo substr($str, 0, -1);
echo substr($str, 3, 1);
echo substr($str, 3);
echo substr($str, -3);                    

Enter the exact script output



Question: 41 (ID:781)

ID: 781


What does the following code print?


                        
function getName(): ?string {
    return "ElNi\u{{{00F}}}o";
}
echo getName();                    



Question: 42 (ID:543)

ID: 543


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





Question: 43 (ID:139)

ID: 139


Which of the following functions will sort an array in ascending order by value, while preserving key associations?





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

ID: 240


Consider the following PHP code snippet:


                        
$who = "World";
echo <<<TEXT
"Hello $who"
TEXT;                    

What will be the output?



Question: 46 (ID:581)

ID: 581


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





Question: 47 (ID:687)

ID: 687


Which of the following functions are part of PHP's internal Iterator interface?





Question: 48 (ID:162)

ID: 162


Which of the following functions can be used as a countermeasure to a Shell Injection attack? Each correct answer represents a complete solution. Choose all that apply.





Question: 49 (ID:625)

ID: 625


What is the best approach for converting this string:


                        
$string = "a=10&b[]=20&c=30&d=40+50";

// Into this array?

array(- [ ] {
      ["a"]=>
      string(- [ ] "10"
      ["b"]=>
      array(- [ ] {
        [0]=>
        string(- [ ] "20"
      }
      ["c"]=>
      string(- [ ] "30"
      ["d"]=>
      string(- [ ] "40 50"
}                    



Question: 50 (ID:783)

ID: 783


What is the result of the following code?


                        
class MyCollection {
    private $coll = [];    
    public function add(?int $x): void {
        $this->coll[] = $x ?? 0;
    }   
    public function getElements(): iterable {
        return $this->coll;
    }
}

$collection = new MyCollection();
$collection->add(null);
$collection->add(1);
$collection->add(0);
print_r($collection->getElements());                    



Question: 51 (ID:117)

ID: 117


Consider the following PHP code snippet:


                        
class A {
    static $word = "hello";
    static function hello() {
        print static::$word;
    }
}
class B extends A {
    static $word = "bye";
}
B::hello();                    

What will be the output on running the above mentioned code snippet?



Question: 52 (ID:189)

ID: 189


Which of the following is used to retrieve the namespaces declared in an XML document from a SimpleXMLElement object?





Question: 53 (ID:774)

ID: 774


What is the result of the following code?


                        
$a = null;
$b = 1;
$c = 'c';

echo $a ?? '!a';
echo $b ?? '!b';
echo $c ?? '!c';
echo $d ?? '!d';                    



Question: 54 (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: 55 (ID:265)

ID: 265


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





Question: 56 (ID:109)

ID: 109


Consider the following PHP script:


                        
$var1 = ["foo", "bar", "hello", "world", "PHP", "nice"];
$var2 = ["foo", "bar", "hello", "PHP", "nice", "language"];

echo count(array_merge(array_diff($var1, $var2), array_diff($var2, $var1)));                    

What will be the output of the script?



Question: 57 (ID:214)

ID: 214


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





Question: 58 (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: 59 (ID:747)

ID: 747


What is the output of the following code?


                        
$a  = ['1' => "A", 1 => "B", 2 => "D"];
echo count($a);                    



Question: 60 (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: 61 (ID:704)

ID: 704


When running PHP's built in FastCGI Process Manager (FPM) which of the following statements are true ?





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

ID: 78


You run the following code:


                        
$array = ['a1' => 'x', 'a2' => 'e', 'a3' => 'z'];
ksort($array);
foreach($array as $key => $value) {
  print "$key = $value ";
}                    

What will be the output?



Question: 64 (ID:776)

ID: 776


What is the result of tht following code?


                        
echo 1 <=> 2;
echo 'aa' <=> 'zz';
echo [1,2,3] <=> [7,8,9];                    



Question: 65 (ID:696)

ID: 696


When working with unfamiliar code, what is the best way to find out in which file a class is defined ?





Question: 66 (ID:12)

ID: 12


Consider the following script:


                        
<?= strtotime("january 1, 1901"); ?>
                    

What will be the output of the above PHP script if the older versions of glibc are present in the operating system?



Question: 67 (ID:118)

ID: 118


Which operator can be used to decide whether or not an object of a class is inheriting property from another class?





Question: 68 (ID:29)

ID: 29


You have been given a code snippet as follows:


                        
$somearray = ["hi", "this is a string", "this is a code"];                    

You want to iterate this array and modify the value of each of its elements. Which of the following is the best possible to accomplish the task?



Question: 69 (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: 70 (ID:63)

ID: 63


You run the following PHP script:


                        
$a = "b";
$b = 20;
echo $$a;                    

What will be the output?



Question: 71 (ID:431)

ID: 431


What would be output when the following code is run?


                        
class M {
   function m() {
      echo "M";
   }
   function construct() {
      echo "mmm";
   }
}
$m = new M();
$m->m();                    



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:61)

ID: 61


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





Question: 74 (ID:104)

ID: 104


What will be the output of the following PHP script?


                        
$array = [
    'a' => 'One', 
    'b' => 'Two', 
    'c' => [
        'd' => 'Three', 
        'e' => 'Four'
   ]
];
function print_element($array) {
    extract($array);
    return $c['e'];
 }
 print print_element($array);                    



Question: 75 (ID:67)

ID: 67


You run the following script:


                        
$a = 6 - 10 % 4;
echo $a;                    

What will be the output?