Home / CSE / PHP - CS :: Operators and Expressions in php

CSE :: PHP - CS

  1. What will be the output of the following PHP code ?

    <?php

    $one = "one";

    $two = "two";

    print("$one$two");

    ?>

  2. A.

     onetwo

    B.

     $one$two

    C.

     one

    D.

     error


  3. What will be the output of the following PHP code ?

    <?php

    $one = "one";

    $two = "two";

    print($one==$two);

    ?>

  4. A.

     true

    B.

     false

    C.

     nothing

    D.

     error


  5. What will be the output of the following PHP code ?

    <?php

    $one = "one";

    $two = "one";

    print($one == $two);

    ?>

  6. A.

     true

    B.

     false

    C.

     1

    D.

     error


  7. What will be the output of the following PHP code ?

    <?php

    print("this"."was"."a"."bad"."idea");

    ?>

  8. A.

     thiswasabadidea

    B.

     this was a bad idea

    C.

     nothing

    D.

     error


  9. What will be the output of the following PHP code ?

    <?php

    define("GREETING", "PHP is a scripting language");

    echo $GREETING;

    ?>

  10. A.

     $GREETING

    B.

     no output

    C.

     PHP is a scripting language

    D.

     GREETING


  11. What will be the output of the following PHP code ?

    <?php

    class Constants

    {

    define('MIN_VALUE', '0.0');

    define('MAX_VALUE', '1.0');

    public static function getMinValue()

    {

    return self::MIN_VALUE;

    }

    public static function getMaxValue()

    {

    return self::MAX_VALUE;

    }

    }

    echo Constants::getMinValue();

    echo Constants::getMaxValue();

    ?>

  12. A.

     0.01.0

    B.

     01

    C.

     No output

    D.

     ERROR


  13. What will be the output of the following PHP code ?

    <?php

    define("__LINE__", "PHP is a scripting language");

    echo __LINE__;

    ?>

  14. A.

     PHP is a scripting language

    B.

     __LINE__

    C.

     2

    D.

     ERROR


  15. What will be the output of the following PHP code ?

    <?php

    define('IF', 42);

    echo "IF: ", IF;

    ?>

  16. A.

     IF:42

    B.

     No output

    C.

     IF:

    D.

     ERROR


  17. What will be the output of the following PHP code ?

    <?php

    define("NEW_GOOD_NAME_CONSTANT", "I have a value");

    define("OLD_BAD_NAME_CONSTANT", NEW_GOOD_NAME_CONSTANT);

    echo NEW_GOOD_NAME_CONSTANT;

    echo OLD_BAD_NAME_CONSTANT;

    ?>

  18. A.

     I have a value

    B.

     I have a valueI have a value

    C.

     ERROR

    D.

     I have a valueNEW_GOO_NAME_CONSTANTS


  19. What will be the output of the following PHP code ?

    <?php

    define("VAR_NAME","test");

    ${VAR_NAME} = "value";

    echo VAR_NAME;

    echo ${VAR_NAME};

    ?>

  20. A.

     test

    B.

     testtest

    C.

     testvalue

    D.

     error, constant value cannot be changed