Font size
WorksheetsIntro to PHP
Total questions: 15
Worksheet time: 8mins
Which tag is used for php
<?php
?>
<style>
<php ?>
<php
/php>
$a="deepan";
$b="Deepan";
if(strcmp($a,$b))
{
echo "equal";
}
else{
echo " not equal";}
Output is
Equal
Not equal
Error
None
What is the output of the PHP code.
<?php
$a=0;
$a = 5>2 ?$b=6 : $b=8;
print("$a $a");?>
6
66
68
88
Websites that contain PHP coding have what file extension?
index.html
index.php
index.htmlphp
index.ppt
When concatenating strings, you use what symbol in PHP?
A comma ,
A plus sign +
a hyphen -
a full stop .
What symbol represents the name for a variable?
$variable
#variable
!variable
?variable
PHP is a ............
Open Source Language
Widely Used Language
Server side scripting language
All of the above
Which of the following is the correct way of defining a variable in PHP?
$variable name = value;
$variable_name = value;
$variable_name = value
$variable name as value;
Find the output
<?php
$x = 5;
{ $x = 10;
echo $x;
}
echo $x;
?>
105
510
1010
What is the Output
<?php
$color=red;
echo "$color";
?>
red
$color
No answer
Error
Which of the following is the correct code snippet for a foreach statement in PHP?
foreach ($variable as $key => $value)
foreach ($variable => $key as $value)
foreach ($ctr = 0; $ctr < $array_size; $ctr++)
foreach ($variable => $key => $value)
Identify the invalid short hand assignment operator?
+=
-=
=*
/=
<?php
$i = 0;
while ($i<=5) {
echo $i. " ";
$i++;
}
?>
output for the above code is:
0 1 2 3 4 5
0
1
2
3
4
5
1
2
3
4
5
1 2 3 4 5
Which of the following function is used to get length of a string?
size()
strlen()
length
None of the above
What is the output of the PHP code.
<?php
if(4>5)
{print("Hurray..");}
print("yes");
?>
yes
hurray..yes
Hurray..Yes
none of the above
