ExamVeda
Login
Home
1
What will be the output of the following PHP code ?
<?php
"Hello World"
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
If you need to output something onto the screen you’ll need to use echo or print_r.
2
What will be the output of the following PHP code ?
<?php
print_r "Hello world"
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
The statement should be print_r(‘Hello World’) to print Hello world. Also if there is only one line then there is no requirement of a semicolon, but it is better to use it.
3
What will be the output of the following PHP code ?
<?php
$color = "red";
echo "$color";
echo "$COLOR";
echo "$Color";
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
In PHP, all variables are case-sensitive.
4
What will be the output of the following PHP code ?
<?php
 # echo "Hello world";
 echo "# Hello world"; 
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
# is a single line comment.
5
What will be the output of the following PHP code ?
<?php
echo "Hello World"
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
You can use tags like italics, bold etc. inside php script.
6
What will be the output of the following PHP code ?
<?php
echo "echo "Hello World"";
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
It would have printed echo “Hello world” if the statement was echo “echo ”Hello World””;.
7
What will be the output of the following PHP code ?
<?php
<?php
echo "Hello world";
?>
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
You can not have php tags inside a php tag.
8
What will be the output of the following PHP code ?
<?php
$color = red;
echo "$color";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
To print red remove the .
9
What will be the output of the following PHP code ?
<?php
$color = red;
echo "$color" . red ;
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
Use of undefined constant red.
10
What will be the output of the following PHP code ?
<?php
$color1 = red;
$color2 = green;
echo "$color1"."$color2";
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
It has to be $color1 = “red”; and $color2 = “green”; therefore the error.