Online Test for PHP

  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. How to typecast a variable to Boolean?
    $var = $var == $var;
    $var = (true)$var;
    $var = (bool)$var;
    Variable cannot be typecast in Boolean


  1. If parent class has Final method abc(). Method abc() can be overridden in child class.
    True
    False

  1. PEAR stands for?
    PHP Extension and Application Record
    PHP Extended and Application Repository
    PHP Extension and Application Repository
    PHP Extension and Applicable Repository

  1. include_once is a ________.
    Function
    Statement
    Language Constructor
    All of the above


  1. PHP stands for
    Process Hypertext Preprocessor
    Preprocessor Hypertext
    Hypertext Preprocessor
    None of the above

  1. Static properties can be accessed through the object using the arrow operator ->.
    True
    False

  1. Which object-oriented pattern would you use to implement a class that must be instantiated only once for the entire lifespan of a script?
    Model-view-controller
    Abstract factory
    Singleton
    Proxy

  1. Find Error/Output in follwing code:
  2.                                 
    <?php
    
    $strings 
    'test test';
    if (
    ctype_alpha($strings)) {
      echo 
    "The string consists of all letters.";
    } else {
      echo 
    "The string does not consist of all letters.";
    }
    ?>
    The string does not consist of all letters.
    The string consists of all letters.
    Fatal Error
    Syntax Error

Post Your Question
Social Sharing
Search