Home

Php Programming MCQ Question with Answer

Php Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Download Php Programming MCQ Question Answer PDF

Question No : 36
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();
?>

0.01.0
01
No output
ERROR

Question No : 37
What will be the output of the following PHP code ?

 <?php  $color1 = red;
$color2 = green;
echo $color1 + $color2;
?>

redgreen
red green
0
error

Question No : 38
What will be the output of the following PHP code?

 <?php  $age = array(Peter=>35, Ben=>37, Joe=>43);
print_r(array_change_key_case($age, CASE_UPPER));
?>

Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
Array ( [peter] => 35 [ben] => 37 [joe] => 43 )
Array ( [PETER] => 35 [BEN] => 37 [JOE] => 43 )
Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 )

Question No : 39
Say you want to calculate the date 45 days from the present date which one of the following statement will you use?

totime(+45)
totime(+45 days)
strtotime(+45 days)
strtotime(-45 days)

Question No : 40
What will be the output of the following PHP code?

     <?php      echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');
?>

TRUE
FALSE
Valid
Invalid

Question No : 41
What will be the output of the following PHP code ?

 <?php  define(__LINE__, PHP is a scripting language);
echo __LINE__;
?>

PHP is a scripting language
__LINE__
2
ERROR

Question No : 42
What will be the output of the following PHP code ?

 <?php  /*echo Hello world;
*/ ?>

Hello world
Nothing
Error
/* Hello world */