Online Test for PHP

  1. Find Error/Output in follwing code:
  2.                                 
    <?php
    
    class MyClass
    {
        const 
    CONST_VAR 'Right';
        function 
    showConstant() {
            echo  $this->CONST_VAR;
        }
    }
    $class = new MyClass();
    $class->showConstant();
    ?>
    Right
    No output
    Undefined property
    None of the above

  1. PECL stands for?
    PHP Extension Community Laboratory
    PHP Extension Combined Library
    PHP Export Community Library
    PHP Extension Community Library


  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. In terms of keywords and language syntax, PHP is similar to?
    C
    COBOL
    FORTRAN
    .Net

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

  1. How to typecast a variable to Boolean?
    $var = $var == $var;
    $var = (true)$var;
    $var = (bool)$var;
    Variable cannot be typecast in Boolean


  1. Which is correct statement to terminate PHP statement?
    Semicolon at the end of each statement
    The closing tag of a block of PHP code automatically implies a semicolon;
    Colon at the end of each statement
    A & B

  1. Find Error/Output in follwing code:
  2.                                 
    <?php
    
    $email  
    'sumit@gmail.com';
    $user strstr($email'@'true);
    echo 
    $user;
    ?>
    sumit
    @gmail.com
    gmail.com
    sumit@

  1. What is the name of function used to convert an array into a string?
    explode()
    glue()
    implode()
    None of the above

  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

Post Your Question
Social Sharing
Search