Online Test for PHP

  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. 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. If class implementing the interface does not use exact same method signatures as are defined in the interface. Will show
    No Error
    Fatal Error
    Warning Error
    Notice Error

  1. What function split an array into chunks?
    array_chunk()
    array_split()
    array_split_chunk
    array_chunks()

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

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


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

  1. The variable name is case-sensitive in PHP.
    True
    False

  1. If property of class is declare using var then PHP5 will treat the property as?
    Protected
    Private
    Public
    Final

  1. What will range('a', 'z') return?
    Find difference between 'a' to 'z'
    An alphabetically ordered array of letters from 'a' to 'z'
    Will only apply on integer value
    None of the above

Post Your Question
Social Sharing
Search