Main Snake Zend Zend Questions Exam Quicktest MZend

1h 30m 00s


Question: 1 (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: 2 (ID:569)

ID: 569


Consider the following script:


                        
$string = "<b>I like 'PHP' & I think it is \"cool\"</b>";
var_dump(htmlentities($string, ENT_QUOTES));
var_dump(htmlspecialchars($string));                    

In this script, do the two var_dump() calls produce the same string? Why or Why Not?



Question: 3 (ID:304)

ID: 304


Which of the following functions will you use to copy data between two opened files?





Question: 4 (ID:770)

ID: 770


Which class of HTTP status code is used for error conditions?





Question: 5 (ID:632)

ID: 632


What is the output of the following script?


                        
class ClassOne {
    protected $a = 10;
    public function changeValue($b) {
        $this->a = $b;
    }
}

class ClassTwo extends ClassOne {
    protected $b = 10;
    public function changeValue($b) {
        $this->b = 10;
        parent::changeValue($this->a + $this->b);
    }
    public function displayValues() {
        print "a: {$this->a}, b: {$this->b}\n";
    }
}

$obj = new ClassTwo();
$obj->changeValue(20);
$obj->changeValue(10);
$obj->displayValues();                    



Question: 6 (ID:404)

ID: 404


What is the PHP function used to determine the length of a string?





Question: 7 (ID:378)

ID: 378


How do you determine the number of elements in array?





Question: 8 (ID:649)

ID: 649


Which of the following cases are cases when you should use transactions?





Question: 9 (ID:255)

ID: 255


You have to select persons whose age is between twenty-five and forty from a database named HumanResource. Which of the following criteria will you use in the query to accomplish the task?





Question: 10 (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: 11 (ID:694)

ID: 694


What happens when the code below is executed ?


                        
class foo {
  private $variable;
  function __construct()  {
    $this->variable = 1;
  }

  function __get($name)  {
    return $this->$name;
  }
}
$a = new foo;
echo $a->variable;                    



Question: 12 (ID:281)

ID: 281


Which of the following superglobals can you use to fetch a cookie from the client's side? Each correct answer represents a complete solution. Choose all that apply.





Question: 13 (ID:580)

ID: 580


What does the following code print?


                        
echo 2 <=> 1;                    



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

ID: 210


Which of the following retrieves the child nodes of a specified XML node?





Question: 17 (ID:236)

ID: 236


You want to parse the following string in PHP:


                        
$some_string="Student\tJohn\nMichel\tMaria";                     

Which of the following PHP functions will you use to parse the string according to the \t and \n characters?



Question: 18 (ID:72)

ID: 72


What will be the output of the following code snippet?


                        
$a = 1;
$b = 2;
$c = 0xAF;
$d = $b + $c;
$e = $d * $b;
$f = ($d + $e) % $a;
print($f + $e);                    



Question: 19 (ID:402)

ID: 402


The str_pad() function is used pad a string to a given length using another string. What is the output of the following PHP script?


                        
$number = 5;
$len    = 3;
$pad    = '0';
echo str_pad($number, $len, $pad, STR_PAD_LEFT);                    



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

ID: 711


Which is a valid way for calling test function?


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



Question: 22 (ID:646)

ID: 646


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





Question: 23 (ID:218)

ID: 218


What are possible value of the following code, if $a and $b variable are defined in current scope script?


                        
echo ($a <=> $b);
                    



Question: 24 (ID:790)

ID: 790


Give the following function signature:


                        
function a(): iterable {
    //
}                    

What actual data types are acceptable for this function to return?



Question: 25 (ID:377)

ID: 377


Which of the following statements best describes what happens to an array when array_shift() is called on it?





Question: 26 (ID:202)

ID: 202


You have given the following XML data in the tasks.XML file:


                        
<?xml version="1.0" encoding="ISO-8859-1" ?>
<tasklist>
  <note>
    <tasks>Validate data</tasks>
    <details>String Validation</details>
  </note>
  <note>
    <tasks>Secure data</tasks>
    <details>Encryption</details>
  </note>
</tasklist>                    

Now, you run the following PHP script:



Question: 27 (ID:244)

ID: 244


A table named employees is given below:



Which of the following statements would return the employees' names, in ascending order, based on their last name and first name?



Question: 28 (ID:194)

ID: 194


Which function is used to set up start and end element handlers?





Question: 29 (ID:75)

ID: 75


What will be the output of the following PHP code?


                        
array_combine(array(1,2,3,6), array(4,5,6));                    



Question: 30 (ID:525)

ID: 525


What is the best way to ensure the distinction between filtered / trusted and unfiltered / untrusted data?





Question: 31 (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: 32 (ID:66)

ID: 66


Which of the following will you use to iterate a PHP associative array?





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

ID: 507


What is the correct way to add 1 to the $count variable?





Question: 36 (ID:394)

ID: 394


Remembering that keys are not reset when using natsort(), what is the output of the following PHP script?


                        
$filenames = array(
    'img12.png',
    'img7.png',
    'img21.png',
    'img1.png'
);

natsort($filenames);
$values = array_values($filenames);
echo $values[1];                    

Enter the exact script output



Question: 37 (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: 38 (ID:730)

ID: 730


What is the output of the script below ?


                        
$i = 1;
do {
    $i++;
} while ($i===0);
echo $i;                    



Question: 39 (ID:430)

ID: 430


What is the output of the following:


                        
$m = 3;
$n = 0;
function l() {
   $m = 0;
   $m++;
   global $n;
   return array($n,$m);
}
echo implode((L(l())),',');                    



Question: 40 (ID:290)

ID: 290


Which of the following functions can be used to get whether or not a file is readable?





Question: 41 (ID:272)

ID: 272


Which of the following header codes is used for redirection?





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

ID: 222


Which of the following functions will you use to get the output from the string ? Each correct answer represents a complete solution. Choose all that apply.





Question: 44 (ID:599)

ID: 599


Which of the following functions allow you to introspect the call stack during execution of a PHP script?





Question: 45 (ID:686)

ID: 686


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





Question: 46 (ID:523)

ID: 523


Consider the following code:


                        
session_start();    
if(!empty($_REQUEST['id']) && !empty($_REQUEST['quantity']))  {
    $id = scrub_id($_REQUEST['id']);
    $quantity = scrub_quantity($_REQUEST['quantity'])
    $_SESSION['cart'][] = array('id' => $id, 'quantity' => $quantity)
}
/* .... */                    

What potential security hole would this code snippet produce?



Question: 47 (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: 48 (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: 49 (ID:407)

ID: 407


What is the output of the following PHP script?


                        
$foo = 'bar';
echo '$foo\'' . "$foo\'";                    



Question: 50 (ID:572)

ID: 572


How do you declare the return type of a function?





Question: 51 (ID:55)

ID: 55


Which of the following is NOT a valid PHP variable name?





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

ID: 408


What is the output of the following script?


                        
$str = 'val1,val2,,val4,';
echo count(explode(',', $str));                    

Enter the exact script output



Question: 55 (ID:261)

ID: 261


Which of the following are the limitations of the prepared statements? Each correct answer represents a complete solution. Choose all that apply.





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

ID: 115


Which of the following allows a programmer to set a string value for the object that will be used if the object is ever used as a string?





Question: 58 (ID:260)

ID: 260


You are using a database named SalesDB to keep all sales records. The SalesDB database contains a table named Orders. You are required to create a new table named OldOrders and transfer all the data from the Orders table to the new table. Which of the following statements will you use to accomplish the task?





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

ID: 545


How do you declare a function to accept a variable (unknown) number of arguments in PHP 7?





Question: 64 (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: 65 (ID:452)

ID: 452


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





Question: 66 (ID:336)

ID: 336


What is the output of the following PHP script?


                        
$arr = array(1, 2, 3, 4);
foreach ($arr as $value) {
    $value -= 1;
}

foreach ($arr as &$value) {
    $value *= 2;
}

foreach ($arr as $v) {
    if ($v <= 8) {
        echo $v;
    }
}                    



Question: 67 (ID:81)

ID: 81


What will be the output of the following code snippet?


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



Question: 68 (ID:241)

ID: 241


Fill in the blank with the appropriate term. The ____ function is used to reverse a given string. *Matching is case-insensitive.





Question: 69 (ID:494)

ID: 494


Which function would transform the string "excellent PHP functions" into the string "Excellent PHP Functions"?





Question: 70 (ID:64)

ID: 64


You run the following script:


                        
10 = $a;
echo $a;                    

What will be the output?



Question: 71 (ID:636)

ID: 636


When using a function such as strip_tags, are markup-based attacks still possible?





Question: 72 (ID:532)

ID: 532


When an object is serialized, which method will be called, automatically, providing your object with an opportunity to close any resources or otherwise prepare to be serialized?





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

ID: 370


What line should be added to the cleanArray() function below to ensure this script outputs 1525hello?


                        
function cleanArray($arr) {
    $functions = array();
    /** line **/
    $ret = $arr;
    foreach ($functions as $func) {
        $ret = $func($ret);
    }
    return $ret;
}

$values = [15, '', 0, 25, 'hello', 15];
foreach (cleanArray($values) as $v) {
    echo $v;
}                    



Question: 75 (ID:298)

ID: 298


Which of the following file functions can be used to indicate the current position of the file read/write pointer?