Online Test for PHP

  1. What is input sanitization?
    Secure user input
    Converting input into a format that PHP supports
    Removing or cleaning potentially malicious user input.
    All of the above

  1. $this is a reference to the calling object
    True
    False


  1. Find Error/Output in follwing code:
  2.                                 
    <?php
    
    $val1 
    42;
    if(
    ctype_digit($val1)) {
      echo 
    "Integer";
    } else {
      echo 
    "Not Integer";
    }

    $val2 '42';
    if(
    ctype_digit($val2)) {
      echo 
    "Integer";
    } else {
      echo 
    "Not Integer";
    }
    ?>
    Not Integer Integer
    Integer Not Integer
    Integer Integer
    Not Integer Not Integer

  1. Find wrong statement
    A class may contain its own constants, properties, and methods.
    Basic class definitions begin with the keyword class, followed by a class name, followed by a pair of curly braces which keeps the definitions of the properties and methods.
    A "class" is not a PHP reserved word.
    The class name can be any valid label, provided it is not a PHP reserved word.

  1. _______ function is used to sort an array in ascending order by value while preserving key associations.
    ksort()
    asort()
    krsort()
    usort()

  1. Parent constructors are not called implicitly if the child class defines a constructor.
    True
    False


  1. If cookie expiration time is not set explicitly, what happens to it?
    It expires right away
    It never expires
    It is not set
    It expires at the end of the user's browser session

  1. In which circumstance it is not possible to assign default value to a parameter while declaring a function?
    When the parameter is Boolean
    When the function is being declared as a member of a class
    When the parameter is being declared as passed by reference
    When the function contains only one parameter

  1. To create instance of class "new" keyword is not required.
    True
    False

  1. microtime() returns _______.
    current Unix timestamp with seconds
    current Unix timestamp with nanoseconds
    current Unix timestamp with microseconds
    None of the above

Post Your Question
Social Sharing
Search