Online Test for PHP

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

  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 input sanitization?
    Secure user input
    Converting input into a format that PHP supports
    Removing or cleaning potentially malicious user input.
    All of the above

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

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

  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 name of function used to convert an array into a string?
    explode()
    glue()
    implode()
    None of the above

  1. How are session variables accessed through?
    $_GET
    $_POST
    $_REQUEST
    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