My Report

PHP Programming Practice Test 9


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
$a = "hello";
if (strlen($a))
    print strlen($a);
else
    print "hi";
?>

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

<?php
for ($count = 1; $count < 20; $count++);
    print $count;
?>

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

<?php
$a = 10;
if (1) 
    print "all";
else 
    print "some"
else 
    print "none";
?>

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

<?php
$a = 2;
if ($a-- - --$a - $a)
    print "hello";
else
    print "hi";
?>

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

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

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

<?php
$a = "2";
switch ($a)
{
case 1:
    print "hi";
case 2:
    print "hello";
    break;
default:
    print "hi1";
}
?>

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

<?php
$x;
for ($x = -3; $x < -5; ++$x)
{
    print ++$x;
}
?>

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

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

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

<?php
$i = 0
while ($i != 3)
{
    print "hi";
	$i++;
}
?>

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

<?php
$a = 10;
if (0) 
    print "all";
 if 
 else 
     print "some"
?>

 

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.