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 default value for the "max_execution_time" setting when running PHP as a CLI SAPI ?

2.What happens when the script below is executed ?


  <?php
    namespace CustomArea;
    error_reporting(E_ALL);
    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.Assuming that the code below is in a file named "test.php" and that PHP has full rights over the file, what happens if the file is executed from the command line without any arguments ?


  exec("rm -f " . dirname(__FILE__) . "/" .  $argv[0]);

4.What is the output of the code below ?

  
    <?php
    $a = array('one'=>'php', 'two'=>'javascript', 'three'=>'python');
    $b = array('python', 'javascript', 'php');

    if(array_values(array_reverse($a)) === $b)
      echo 'true';
    else
      echo 'false';
  

5.When dealing with cloned objects in PHP, which of the following statements are true ?

6.What is the best way to store and verify passwords in PHP ?

7.Which of the following is not valid syntax for creating a new array key?

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

9.Which function would you use to add an element to the beginning of 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.Transactions are used to...

12.How does one access standard input/output and error streams in PHP 5?

13.What are the three access modifiers that you can use in PHP objects?

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

15.In PHP 5 you can use the ______ operator to ensure that an object is of a particular type. You can also use _______ in the function declaration.

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

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

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

19.Which php.ini directive should be disabled to prevent the execution of a remote PHP script via an include or require construct?

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

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

22.What is the best measure one can take to prevent a cross-site request forgery?

23.Consider the following code: header("Location: {$_GET['url']}\"); Which of the following values of $_GET['url'] would cause session fixation?

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

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

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

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

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

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

30.One can ensure that headers can always be sent from a PHP script by doing what?

Finish Quiz