My Report

PHP Programming Practice Test 8


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

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

<?php
$i = 10;
$j = 0;
if ($i || ($j = $i + 10)) {
    echo "true";
}
echo $j;
?>

2. 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();
?>

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

<?php
$i = 0;
while(++$i || --$i)
{   
    print $i;
}
?>

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

<?php
$y = 2;
if (--$y == 2 || $y xor --$y)
{
    echo $y;
}
?>

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

<?php
class myObject { }
define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT; 
?>

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

<?php
$one = "one";
$two = "one";
print($one == $two);
?>

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

<?php
$i = 0;
$j = 0;
if ($i && ($j = $i + 10)) {
    echo "true";
}
echo $j;
?>

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

<?php
$i = 0;$j = 1;$k = 2;
print !(( +  + $i + $j) > ($j - $k));
?>

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

<?php
$i = 0;
while (++$i && --$i)
{   
    print $i;
}
?>

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

<?php
echo 5 * 9 / 3 + 9;
?>

 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.