PHP Operators
- What will be the output of the following PHP code ?
<?php
$p = 8; $r = 7; $q = 15;
$s = $p + $r == $q;
print $s;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
First p and r are added and then tested if s = 15, which is true thus return 1.
- What will be the output of the following PHP code ?
<?php
$m = 10; $n = -8; $t = 2;
$k = ++$m && ++$n || ++$t;
echo $k;
echo $m;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
111
- What will be the output of the following PHP code ?
<?php
$p = 10;
$r = $p++; $q = ++$p;
print $p;
print $q;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
First case p is incremented after setting q to p.
- What will be the output of the following PHP code ?
<?php
$p = 20; $q = 20;
if ($p = 12)
$q--;
echo $p;
echo $q--;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
p is set to 20 in the if condition and q is post decremented in the print statement.
- What will be the output of the following PHP code ?
<?php
$p = 2; $q = 2; $r = 2;
echo ++$p + ++$p+$p++; print $p++ + ++$q; print ++$r + $r++ + $p++;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Follow the order of post and pre increments.