PHP Operators
- What will be the output of the following PHP code ?
<?php
$p = 12;
echo ++$p;
echo $p++;
echo $p;
echo ++$p;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
++$p increments a and then prints it,$p++ prints and then increments.
- What will be the output of the following PHP code ?
<?php
$m = 8;
echo $m = ++$m % 9 + ++$m;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Evaluation done from right to left.
- What will be the output of the following PHP code ?
<?php
$str = 'view';
echo 'Inter{$str}Mania';
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Inter{$str}Mania, single quotes are not parsed.
- What will be the output of the following PHP code ?
<?php
$str = 'view';
print "Inter".$str."Mania";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
dereferences the variable/string within.
- What will be the output of the following PHP code ?
<?php
$str = 'view ';
print "Inter{$str}Mania";
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
{$}dereferences the variable within.