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

Code:
<?php
$p = 0;
while ($p++)
{
    print $p;
}
print $p;
?>
  • (A) Error
  • (B) 0
  • (C) 1
  • (D) Nothing
πŸ’¬ Discuss
βœ… Correct Answer: (C) 1
Explanation: As it is a post increment, it checks and then does not enter the loop, thus prints only 1.

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

Code:
<?php
$t = 20;
do
{
    $t++;
}
while ($t < 60);
print $t;
?>
  • (A) Error
  • (B) 60
  • (C) Nothing
  • (D) 20
πŸ’¬ Discuss
βœ… Correct Answer: (B) 60

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

Code:
<?php
$k = 10;
while ($k < 30)
{
    $k++;
}
print $k;
?>
  • (A) 30
  • (B) 10
  • (C) Error
  • (D) Nothing
πŸ’¬ Discuss
βœ… Correct Answer: (A) 30

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

Code:
<?php
while()
{
    print "While loop...";
}
?>
  • (A) Nothing
  • (B) Error
  • (C) While loop...
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (B) Error

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

Code:
<?php
do
{
    print "Hello";
}
while(0);
print "World";
?>
  • (A) World
  • (B) Hello
  • (C) HelloWorld
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) HelloWorld

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

Code:
<?php
$n = 0;
do
{
    print $n;
    $n++;
}
while ($n != 5);
?>
  • (A) 0
  • (B) 5
  • (C) 01234
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 01234

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

Code:
<?php
$num = 2;
while ($num != 5)
{
    print "Executed...";
	$num++;
}
?>
  • (A) Executed...
  • (B) Executed...Executed...
  • (C) Executed...Executed...Executed...
  • (D) Executed...Executed...Executed...Executed...Executed...
πŸ’¬ Discuss
βœ… Correct Answer: (C) Executed...Executed...Executed...

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

Code:
<?php
$num = 2;
while ($num < 5)
{
    print "Hello";
    $num--;
}
print "World";
?>
  • (A) Error
  • (B) World.......infinite time
  • (C) Nothing
  • (D) Hello......infinite time
πŸ’¬ Discuss
βœ… Correct Answer: (D) Hello......infinite time
Explanation: Since the value of $num will always be less than 5 so while loop will never end.
It will print hello for infinite times .

Q. Both POSIX regex and PERL regex are example of _____

  • (A) Delimitering
  • (B) Tokenizing
  • (C) Regular expressions
  • (D) None of them
πŸ’¬ Discuss
βœ… Correct Answer: (C) Regular expressions
Explanation: Both POSIX regex and PERL regex are example of Regular expressions.

Q. Which of the following function is not listed in PHP6?

  • (A) ereg()
  • (B) eregi()
  • (C) ereg_replace()
  • (D) All of them
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of them