Test HTTP Requests Tools Blog PHP Quiz API Log In With Github
Test HTTP Requests Tools Blog PHP Quiz API Log In With Github
We have updated the website and our policies to make sure your privacy rights and security are respected.
Click here to learn more about the way our website handles your data.

Remove this message.

Advanced PHP Quiz

Topic: PHP/MySQL Last updated on: 01-22-2018

This is an advanced PHP Quiz. It contains questions for seasoned developers about namespaces, traits, handlers and settings, command line execution, exception handling, OOP and other modern PHP features and functions.

1.What is the output of the following script ?

  function generate() {
      for ($i = 1; $i <= 3; $i++) 
          yield $i;
  $generator = generate();
    echo "Is Array";
    echo "Is Object";
    echo "Is none of the above";

2.What happens when the script below is executed ?

    namespace CustomArea;
    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);

3.Which of the statements about traits below are true ?

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

5.How does Opcode Cache improve performance in PHP 5.5+ ?

6.What happens if you execute the code below ?

    class someclass
        public $someprop;
        function __construct()
            $this->someprop = 1;

    function somefunc(&$instance) {

    $instance = new someclass;

7.What is the output of the following PHP script?

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

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

9.Which from the following list is not an appropriate use of an array?

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

11.Given the following array: $array = array(1,1,2,3,4,4,5,6,6,6,6,3,2,2,2); The fastest way to determine the total number a particular value appears in the array is to use which function?

12.The ____ construct is particularly useful to assign your own variable names to values within an array.

13.What is the output of the following PHP code? define("FOO", 10); $array = [10 => FOO,"FOO" => 20]; print $array[$array[FOO]] * $array["FOO"];

14.What SimpleXML function is used to parse a file?

15.Which technique should be used to speed up joins without changing their results?

16.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); }

17.What would you replace ??????? with, below, to make the string Hello, World! be displayed? function myfunction() { /* ??????? */ print $string; } myfunction("Hello, World!");

18.What is wrong with the following code? function duplicate($obj) { $newObj = $obj; return $newObj; } $a = new MyClass(); $a_copy = duplicate($a); $a->setValue(10); $a_copy->setValue(20);

19.What is the primary difference between a method declared as static and a normal method?

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

21.What three special methods can be used to perform special logic in the event a particular accessed method or member variable is not found?

22.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?

23. Which of the following list of potential data sources should be considered trusted?

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

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

26.What is the output of the following code? $string = "14302"; $string[$string[2]] = "4"; print $string;

27.Consider the following script: $oranges = 10; $apples = 5; $string = "I have %d apples and %d oranges"; ??????? What could be placed in place of ?????? to output the string: "I have 5 apples and 10 oranges"

28.Which PCRE regular expression will match the string PhP5-rocks

29.If you would like to store your session in the database, you would do which of the following?

30.If you would like to change the session ID generation function, which of the following is the best approach for PHP 5?

Finish Quiz