PHP & MySQL

20 Questions | Total Attempts: 385

SettingsSettingsSettings
Please wait...
PHP Quizzes & Trivia

This test is for checking your ability to join ITP/Web Development


Questions and Answers
  • 1. 
    How many times will the function counter() be executed in the following code? function counter($start, &$stop) { if ($stop > $start) { return; } counter($start--, ++$stop); } $start = 5; $stop = 2; counter($start, $stop);
    • A. 

      3

    • B. 

      4

    • C. 

      5

    • D. 

      6

  • 2. 
    When a class is defined as final it:
    • A. 

      Can no longer be extended by other classes.

    • B. 

      Means methods in the class are not over-loadable.

    • C. 

      Cannot be defined as such, final is only applicable to object methods.

    • D. 

      Is no longer iteratable.

  • 3. 
    What is the maximum size of the VARCHAR column type?
    • A. 

      255 Bytes

    • B. 

      255 Characters

    • C. 

      512 Bytes

    • D. 

      512 Characters

    • E. 

      No Limit

  • 4. 
    What is the output of the following code? [code] class test { public $value = 0; function test() { $this->value = 1; } function __construct() { $this->value = 2; } } $object = new test(); echo $object->value;
    • A. 

      2

    • B. 

      1

    • C. 

      0

    • D. 

      3

    • E. 

      No Output, PHP will generate an error message.

  • 5. 
    Which of the following data types cannot be directly manipulated by the client?
    • A. 

      Cookie Data

    • B. 

      Session Data

    • C. 

      Remote IP address

    • D. 

      User Agent

  • 6. 
    Which of the following statements is correct?
    • A. 

      Interfaces can extend only one interface

    • B. 

      Interfaces can extend more than one interface

    • C. 

      Interfaces can inherit a method from different interfaces

    • D. 

      Interfaces can redeclare inherited methods

  • 7. 
    What super-global should be used to access information about uploaded files via a POST request?
    • A. 

      $_SERVER

    • B. 

      $_ENV

    • C. 

      $_POST

    • D. 

      $_FILES

    • E. 

      $_GET

  • 8. 
    Which of the following statements about PHP is true? (Choose 3)
    • A. 

      A final class can be derived.

    • B. 

      A final class may be instantiated.

    • C. 

      A class with a final function may be derived.

    • D. 

      Static functions can be final.

    • E. 

      Properties can be final.

  • 9. 
    What is the output of the following code? $first = "second"; $second = "first"; echo
    • A. 

      First

    • B. 

      Second

    • C. 

      An empty string

    • D. 

      An error

  • 10. 
    What is the output of the following code? <?php for ($i = 0; $i < 1.02; $i += 0.17) { $a[$i] = $i; } echo count($a); ?>
    • A. 

      0

    • B. 

      1

    • C. 

      2

    • D. 

      6

    • E. 

      7

  • 11. 
    What is the output of the following script? <?php function fibonacci (&$x1 = 0, &$x2 = 1){   $x1 = $x2;   $x2 = $result;   return $result; } for ($i = 0; $i < 10; $i++) {    echo fibonacci() . ','; } ?>
    • A. 

      An error

    • B. 

      1,1,1,1,1,1,1,1,1,1,

    • C. 

      1,1,2,3,5,8,13,21,34,55,

    • D. 

      Nothing

  • 12. 
    What is the difference between "print" and "echo" ?
    • A. 

      There is no difference

    • B. 

      Print returns length of data printed and echo does not

    • C. 

      Echo returns length of the data printed and print does not

    • D. 

      Print buffers the output, while echo does not

  • 13. 
    In the function setcookie() what does the 3rd prameter specify?
    • A. 

      The name of the cookie.

    • B. 

      The expiration time of the cookie.

    • C. 

      The value of the cookie.

    • D. 

      The IP address of the cookie's client.

  • 14. 
    Given the following array: $a = array(28, 15, 77, 43); Which function will remove the value 28 from $a?
    • A. 

      Array_shift()

    • B. 

      Array_pop()

    • C. 

      Array_push()

    • D. 

      Array_unshift()

  • 15. 
    Where does the session extension store the session data by default?
    • A. 

      SQLite Database

    • B. 

      MySQL Database

    • C. 

      Shared Memory

    • D. 

      File system

    • E. 

      Session Server

  • 16. 
    What is the difference between DROP a table and TRUNCATE a table ?
  • 17. 
    What are the different types of errors in php ?
  • 18. 
    How can we submit form without submit button ?
    • A. 

      Using XML

    • B. 

      Using Javascript

    • C. 

      Using Cookie

    • D. 

      Using button

  • 19. 
    You have a variable $test that contains sub-strings divided by a dash ("-"). How can you put every sub-string into an array element easily?
    • A. 

      Extract($test, "-");

    • B. 

      Explode("-", $test);

    • C. 

      To_array($test, "-");

    • D. 

      Explode($test, "-");

  • 20. 
    What will the $array array contain at the end of this script? <?php function modifyArray (&$array){    foreach ($array as &$value){       $value = $value + 1;    }    $value = $value + 2;  } $array = array (1, 2, 3); modifyArray($array); ?>
    • A. 

      2, 3, 4

    • B. 

      2, 3, 6

    • C. 

      4, 5, 6

    • D. 

      1, 2, 3