Online Test for PHP

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

  1. In PHP 5, how can you write a class so that some of its properties cannot be accessed from outside its methods?
    By declaring the class as private
    By declaring the property as private
    It cannot be done
    By writing a property overloading method


  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

  1. What is most appropriate way to open file "placementquestion.txt" in write mode?
    openf("placementquestion.txt", "w");
    fopen("placementquestion.txt", "w");
    open("placementquestion.txt", "w");
    fopen("placementquestion.txt", "w+");

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

  1. What is the simplest method of computing the sum of all the elements of an array?
    array_intersect()
    array_count()
    array_sum()
    array_value_count()


  1. Static properties can be accessed through the object using the arrow operator ->.
    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. PHP is an open source software
    True
    False

Post Your Question
Social Sharing
Search