Test HTTP Requests Tools Blog Learn Quizzes Smile API Log In / Sign Up
Test HTTP Requests Tools Blog Learn Quizzes Smile API Log In / Sign Up
« Return to the quizzes list
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?


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


2.What happens when you run the following MySQL Query ?

  
  CREATE TABLE PRIMARY (ID int);
  

3.What is the output of the code below ?


<?php 
  $a = array();
  $a[0] = 1;
  unset($a[0]);
  echo ($a != null) ? 'True' : 'False';

4.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 = "";

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

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

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

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

8.How do you access standard I/O and error streams ?

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

10.What is the output of the following code block? $a = "The quick brown fox jumped over the lazy dog."; $b = array_map("strtoupper", explode(" ", $a)); foreach ($b as $value) { print "$value "; }

11.What is the output of this code snippet? $a = array(0.001 => 'b', .1 => 'c'); var_dump($a);

12.Which function would you use to add an element to the beginning of an array?

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

14.Which of the following tags are an acceptable way to begin a PHP Code block?

15.Which of the following are valid PHP variables?

16.What is the output of the following? $a = 010; $b = 0xA; $c = 2; print $a + $b + $c;

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

18.Which of the following will NOT instantiate a DateTime object with the current timestamp?

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

20.What is the output of the following function? function &find_variable(&$one, &$two, &$three) { if($one > 10 && $one < 20) return $one; if($two > 10 && $two < 20) return $two; if($three > 10 && $three < 20) return $three; } $one = 2; $two = 20; $three = 15; $var = &find_variable($one, $two, $three); $var++; print "1: $one, 2: $two, 3: $three";

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

22.How to access standard error stream in PHP ?

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

24.The _______ method will be called automatically when an object is represented as a string.

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

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

27.Which of the following are not valid ways to embed a variable into a string?

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

29.To force a user to redirect to a new URL from within a PHP 5 script, which of the following should be used?

30.Which functions would be needed to translate the following string: I love PHP 5 to the following? 5 PHP EVOL I

Finish Quiz