PHP Echo & Print MCQs
11. which of the following is correct echo statement?
A. echo "<h2>PHP is Fun!</h2>";
B. echo "PHP is Fun!<br>";
C. echo "PHP ", "is ", "Fun!";
D. All of the above
View Answer
Ans : D
Explanation: All echo statement is correct.
12. which of the following is correct print statement?
A. print "<h2>PHP is Fun!</h2>";
B. print "PHP is Fun!<br>";
C. print "PHP ", "is ", "Fun!";
D. All of the above
View Answer
Ans : D
Explanation: All print statement is correct.
13. What will be the output of the following PHP code?
<?php
echo "This is <i>Letsfindcourse</i>";
?>
A. This is Letsfindcourse
B. This is Letsfindcourse(Letsfindcourse in italic)
C. This is
D. Error
View Answer
Ans : B
Explanation: the output of the following PHP code This is India(India in italic)
14. What will be the output of the following PHP code?
<?php
$arr = array('0' => "Letsfindcourse",
'1' => "Computer",
'2' => "Science",
'3' => "Portal");
print_r($arr[-1]);
?>
A. Portal
B. Letsfindcourse
C. Error
D. No Output
View Answer
Ans : C
Explanation: the output of the following PHP code is Undefined index -1.
15. What will be the output of the following PHP code?
<?php
$arr = array('0' => "Letsfindcourse",
'1' => "Computer",
'2' => "Science",
'3' => "Portal");
print_r($arr[0]);
?>
A. Portal
B. Letsfindcourse
C. Error
D. No Output
View Answer
Ans : B
Explanation: the output of the following PHP code is Letsfindcourse.
16. What will be the output of the following PHP code?
<?php
echo 'This is "letsfindcourse"' ;
?>
A. This is letsfindcourse
B. This is "letsfindcourse"
C. Error
D. No Output
View Answer
Ans : B
Explanation: the output of the following PHP code This is "letsfindcourse".
17. What will be the output of the following PHP code?
<?php
echo "This is "echo statement" ";
?>
A. This is "echo statement"
B. echo statement
C. Error
D. No Output
View Answer
Ans : C
Explanation: the output of the following PHP code Syntax Error, unexpected echo statement.
18. What will be the output of the following PHP code?
<?php
echo "This","is"|"a","PHP"."MCQs";
?>
A. ThisisaPHPMCQs
B. ThisisPHPMCQs
C. Thisis a PHPMCQs
D. Thisis aPHPMCQS
View Answer
Ans : B
Explanation: You can use only comma and dot operator to join strings, other characters do not have the same function.
19. What will be the output of the following PHP code?
<?php
echo "This","is"&"a","PHP"."MCQs";
?>
A. ThisisaPHPMCQs
B. Thisis PHPMCQs
C. This aPHPMCQS
D. ThisaPHPMCQs
View Answer
Ans : D
Explanation: The output for the following PHP code is ThisaPHPMCQs.
20. What will be the output of the following PHP code?
<?php
echo "This","is"@"a","PHP"."MCQs";
?>
A. Thisis@aPHPMCQs
B. ThisaPHPMCQs
C. No Output
D. Error
View Answer
Ans : D
Explanation: The output for the following PHP code is Syntax Error, unexpected @.
Discussion