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.Considering the code below, which of these statements are true?

    ini_set("allow_url_fopen", "1");
    $page = file_get_contents("http://www.codepunker.com");
    echo "Successfully fetched website contents";
    echo "An error has occurred";

2.What is the default value for the "max_execution_time" setting when running PHP as a CLI SAPI ?

3.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;

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

5.Considering the following code which of the statements below is true ?

    class entity {
        public $name;
    $human = new entity();
    $dog = new entity();
    $human->name = 0;
    $dog->name = "";

6.Which of th following statements about object serialization are true ?

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

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

9.Which of the following functions could be used to break a string into an array?

10.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 )

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

12.The following code snippet displays what for the resultant array? $a = array(1 => 0, 3 => 2, 4 => 6); $b = array(3 => 1, 4 => 3, 6 => 4); print_r(array_intersect($a, $b));

13.What is the best way to iterate and modify every element of an array using PHP 5?

14.Given a PHP value, which sample shows how to convert the value to JSON?

15.Transactions are used to...

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

17.What is the best way to ensure that a user-defined function is always passed an object as its single parameter?

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

19.How to access standard error stream in PHP ?

20.When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used?

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

22.Which of the following php.ini directives should be disabled to improve the outward security of your application?

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

24.When comparing two strings, which of the following is acceptable?

25.Which function is best suited for removing markup tags from a string?

26.If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?

27.Consider the following HTML fragment: <select name="???????" multiple> <option value="1">Item #1</option> <!-- ... more options ... --> </select> Which of the following name attributes should be used to capture all of the data from the user in PHP?

28.Setting a HTTP cookie on the client which is not URL-encoded is done how in PHP 5?

29.During an HTTP authentication, how does one determine the username and password provided by the browser?

30.Which of the following is not a valid fopen() access mode:

Finish Quiz