Online Test for PHP

  1. Which is correct syntax to declare constant?
    define("CONSTANT", "Placement Question");
    const CONSTANT = 'Placement Question';
    constant CONSTANT = 'Placement Question';
    A & B

  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. Which of the following is invalid PHP code?
    $_20
    &$myVar
    $20_var
    ${"var"}

  1. Interface constant can be override in class implementing the interface.
    True
    False

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

  1. Which keyword cannot be used while defining property?
    Public
    Static
    Final
    Private


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

  1. A PHP scripting block always starts with
    < ?php ...... ?>
    <@ ....... />
    <% .... %>
    { ..... }

  1. Static properties cannot be initialized using
    expressions
    literal
    constant
    All of the above

  1. In PHP, a class can be inherited from one base class and with multiple base classes.
    True
    False

Post Your Question
Social Sharing
Search