Home » PHP » PHP Constants » Question
  1. What will be the output of the following PHP code ?
    <?php
    class Constants
    {
    define('MIN_VA', '10.10');
    define('MAX_VAL', '20.20');
    public static function getMin()
    {
    return self::MIN_VAL;
    }
    public static function getMax()
    {
    return self::MAX_VAL;
    }
    }
    echo Constants::getMin();
    echo Constants::getMax();
    ?>
    1. Error
    2. 10.10
    3. 20.20
    4. Nothing
    5. None of these
Correct Option: A

In a class constants should be defined const MIN_VAL = 10.10; const MAX_VAL = 20.20; instead.



Your comments will be displayed only after manual approval.