My Report

PHP Operators Test – 3


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
echo 5 * 9 / 3 + 9
?>

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

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

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

<?php
$a = 1; $b = 3;
$d = $a++ + ++$b;
echo $d;
?>

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

<?php
 $a = 5; $b = -7; $c =0; 
 $d = ++$a && ++$b || ++$c;
 print $d; print $a;
?>

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

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

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

<?php
$i = 0;
$x = $i++; $y = ++$i;
print $x; print $y; 
?>

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

<?php
$a = 1; $b = 1; $d = 1;
print ++$a + ++$a+$a++; print $a++ + ++$b; print ++$d + $d++ + $a++;
?>

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

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

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

<?php
$b = 1; $c = 4; $a = 5; 
$d = $b + $c == $a;
print $d;
?>

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

<?php
$a = 10; $b = 10;
if ($a = 5)
    $b--;
print $a;print $b--;
?>

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

<?php
$i = 1;
if ($i++ && ($i == 1))
    printf("Yes\n$i");
else
    printf("No\n$i");
?>

 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

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.