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();
?>
<?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();
?>
A. 0.01.0
B. 01
C. No output
D. ERROR
Answer: Option D
Solution(By Examveda Team)
In a class constants should be defined const MIN_VALUE = 0.0;const MAX_VALUE = 1.0; instead.Related Questions on Operators and Expressions in php
What will be the output of the following PHP code ?
<?php
"Hello World"
?>
A. Error
B. Hello World
C. Nothing
D. Missing semicolon error
What will be the output of the following PHP code ?
<?php
print_r "Hello world"
?>
A. Error
B. Hello World
C. Nothing
D. Missing semicolon error
A. redredred
B. redred
C. red
D. Error
A. # Hello world
B. Hello world# Hello world
C. Hello world
D. Error
Join The Discussion