PHP OOP Development Quiz

39 Questions | Total Attempts: 546

SettingsSettingsSettings
Please wait...
PHP Quizzes & Trivia

In this quiz, we’ll be testing your knowledge on all the different functions of the widely used programming and web development language, PHP! What can you tell us about these functions and how they are used? Let’s find out!


Questions and Answers
  • 1. 
    As of PHP 5.3.0, PHP implements a feature which can be used to reference the called class in a context of static inheritance. How is it called?
    • A. 

      Static class bindings

    • B. 

      Static bindings

    • C. 

      Late static bindings

    • D. 

      Late bindings

    • E. 

      Class bindings

  • 2. 
    The above code will:
    • A. 

      Cause error

    • B. 

      Call local version of strlen

    • C. 

      Call global version of strlen

    • D. 

      Work only as of PHP 5.3 and call local version of strlen

    • E. 

      Work only as of PHP 5.3 and call global version of strlen

  • 3. 
    Which function activates the circular reference collector?
    • A. 

      Gc_rc()

    • B. 

      Gc_enable()

    • C. 

      Crc_enable()

    • D. 

      Gc_activate()

    • E. 

      Crc_activate()

  • 4. 
    Does anonymous functions allow creation of functions without specifying their name?
    • A. 

      Yes

    • B. 

      No

    • C. 

      There is nothing like 'anonymouss functions'

  • 5. 
    Mysql_connect() takes parameters:
    • A. 

      (string, string, string, bool, int)

    • B. 

      (string, string)

    • C. 

      (string, string, string, bool)

    • D. 

      (string, string, string, int, bool)

    • E. 

      (string, string, string, bool, bool)

  • 6. 
    What does PHP stand for?
    • A. 

      PHP: Hypertext Processor

    • B. 

      Private Home Page

    • C. 

      Personal Home Page

    • D. 

      Personal Hypertext Processor

    • E. 

      PHP: Personal Hypertext Processor

  • 7. 
    Is it possible to run several versions of PHP at the same time?
    • A. 

      Yes

    • B. 

      No

    • C. 

      Yes, but only commercial editions of PHP

  • 8. 
    PHP scripts are surrounded by delimiters, which?
    • A. 

    • B. 

      ...

    • C. 

      or

    • D. 

    • E. 

  • 9. 
    All variables in PHP are prefixed with special symbol, which?
    • A. 

      @

    • B. 

      #

    • C. 

      $

    • D. 

      \

    • E. 

      %

  • 10. 
    How do You get information from a form that is submitted using the "get" method?
    • A. 

      Request.QueryString;

    • B. 

      Request.Form;

    • C. 

      Get_request();

    • D. 

      $_GET[];

    • E. 

      Request(GET);

  • 11. 
    In PHP You can use both single quotes (' ') and double quotes (" ") for strings:
    • A. 

      True

    • B. 

      False

    • C. 

      None from above

  • 12. 
    Include files must have file extension *.inc
    • A. 

      True

    • B. 

      False

  • 13. 
    What is the correct way to include file data.php5?
    • A. 

    • B. 

    • C. 

    • D. 

    • E. 

      None from above

  • 14. 
    What is the correct way to connect to MySQL database?
    • A. 

      Connect_mysql("localhost");

    • B. 

      Mysql_open("localhost");

    • C. 

      Dbopen("localhost");

    • D. 

      Mysql_connect("localhost");

    • E. 

      Depends on MySQL server version

  • 15. 
    What is the correct way to add 1 to the variable?
    • A. 

      $variable =+ 1;

    • B. 

      Variable =+1;

    • C. 

      Variable++;

    • D. 

      $variable++;

    • E. 

      Variable +=1;

  • 16. 
    What is the correct way to add comments to PHP code?
    • A. 

      */.../*

    • B. 

      *\...\*

    • C. 

    • D. 

      #...

    • E. 

  • 17. 
    Which one of theese variables has illegal name?
    • A. 

      $myVar

    • B. 

      $my_Var

    • C. 

      $my-Var

    • D. 

      All of them

    • E. 

      None of them

  • 18. 
    Can PHP be executed in Command line?
    • A. 

      Yes

    • B. 

      No

    • C. 

      Only on linux

    • D. 

      Only on Windows

  • 19. 
    What Value $bodytag contains?
    • A. 

      Body text='%black%'

    • B. 

      Body text='black'

    • C. 

      Body text="black"

    • D. 

      None

  • 20. 
    $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user; echo $pass; ?> What set of value it will give?
    • A. 

      Foo:*1023

    • B. 

      Foo*

    • C. 

      *foo

    • D. 

      Foo

    • E. 

      *

  • 21. 
    $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key => $val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?> The above code will result in:
    • A. 

      Fruits[0] = lemon fruits[1] = orange fruits[2] = banana fruits[3] = apple

    • B. 

      Apple banana lemon orange

    • C. 

      Fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange

    • D. 

      Fruits[0] = apple fruits[1] = banana fruits[2] = orange fruits[3] = lemon

    • E. 

      None

  • 22. 
    $Link_ID = odbc_connect("DSN", "user", "pass"); $Return = odbc_autocommit($Link_ID, FALSE); ?> will result in:
    • A. 

      Set autocommit on

    • B. 

      Set autocommit off

    • C. 

      Error in code

    • D. 

      Nothing

  • 23. 
    What's correct result of below code? $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); asort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } ?>
    • A. 

      Apple banana lemon a = orange

    • B. 

      C = apple b = banana d = lemon a = orange

    • C. 

      A = apple b = banana c = lemon d = orange

    • D. 

      Apple banana lemon orange

    • E. 

      Apple banana lemon orange

  • 24. 
    If only one array is given in array_merge() as parameter and the array is numerically indexed, the keys get reindexed in a continuous way.
    • A. 

      The above sentense is true

    • B. 

      The above sentense is false

    • C. 

      Described situation will result in error

  • 25. 
    $array = array('first' => null, 'second' => 4); isset($array['first']); ?> Choose the correct answer.
    • A. 

      Isset returns true

    • B. 

      Isset returns false

    • C. 

      Error in code

  • 26. 
    $email = '[email protected]'; $domain = strstr($email, '@'); echo $domain; ?> Whats the result of above code?
  • 27. 
    What value will it give?
    • A. 

      112345678910

    • B. 

      12345678910

    • C. 

      Error in Code

    • D. 

      Display Nothing

  • 28. 
    $i = 0; while ($i <= 0): echo $i; $i++; endwhile; ?> What value will it give?
    • A. 

      12345

    • B. 

      1

    • C. 

      0

    • D. 

      Displays nothing

    • E. 

      Error in code

  • 29. 
    for ($i = 1; ; $i++) { if ($i > 10) { break; } echo $i; } ?> What result will it give?
    • A. 

      12345678910

    • B. 

      1234567891011

    • C. 

      None

  • 30. 
    $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } echo $value; unset($value); ?> What is the result?
    • A. 

      NULL

    • B. 

      0

    • C. 

      8

    • D. 

      Error in code

  • 31. 
    Which function gets information about the last error that occurred?
    • A. 

      Getlasterror()

    • B. 

      Get_error()

    • C. 

      Get_last_error()

    • D. 

      Error_get_last()

  • 32. 
    Which function sets the error_reporting directive at runtime?
    • A. 

      Set_error()

    • B. 

      Error_reporting()

    • C. 

      Set_error_reporting()

    • D. 

      Set_reporting_errors()

  • 33. 
    Which function generates a user-level error/warning/notice message?
    • A. 

      Trigger_error()

    • B. 

      Error_log()

    • C. 

      Report_error()

    • D. 

      Error_report()

    • E. 

      Log_error()

  • 34. 
    When an object is cloned, PHP 5 will perform a shallow copy of all of the object's properties. Any properties that are references to other variables, will remain references.
    • A. 

      True

    • B. 

      False

  • 35. 
    $rest = substr("abcdef", -3, 1); ?> What dalue does $rest contain?
    • A. 

      E

    • B. 

      A

    • C. 

      F

    • D. 

      D

    • E. 

      C

  • 36. 
    $string = 'Hello World!'; if(stristr($string, 'earth') === FALSE) { echo '"earth" not found in string'; } ?> The above code:
    • A. 

      Outputs: Hello World!

    • B. 

      Outputs: "earth" not found in string

    • C. 

      No output

    • D. 

      Gives error in code

  • 37. 
    India's National Animal?
    • A. 

      Dog

    • B. 

      Line

    • C. 

      Elephant

  • 38. 
    Mahatma Gandhi Born in Pakistan?
    • A. 

      True

    • B. 

      False

  • 39. 
    Mera Bharat ____