Online Test for PHP

  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. The variable name is case-sensitive in PHP.
    True
    False


  1. $this is a reference to the calling object
    True
    False

  1. The break statement ends execution of which of the following?
    while
    for
    switch
    All of the above

  1. Array values are keyed by ______ values (called indexed arrays) or using ______ values (called associative arrays).
    Float, string
    Even number, string
    String, Boolean
    Integer, string

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


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

  1. In which circumstance it is not possible to assign default value to a parameter while declaring a function?
    When the parameter is Boolean
    When the function is being declared as a member of a class
    When the parameter is being declared as passed by reference
    When the function contains only one parameter

  1. Which of the following tags is not a valid way t o begin and end a PHP code block?
    <% %>
    <! !>
    <? ?>
    <?= ?>

  1. By default, PHP stores session data in ______________.
    The filesystem
    A database
    Virtual memory
    Shared memory

Post Your Question
Social Sharing
Search