Font size
WorksheetsPHP
Total questions: 100
Worksheet time: 50mins
Which tag is used for php
<?php
?>
<style>
<php ?>
<php
/php>
What are the two types of array in php
Indexed, sequence
Associative, sequence
Indexed, associative
None
$a=array("Timmy","Jimmy");
Is an example of
Indexed array
Associative array
Sequence array
None
$a=array(10=>"Jimmy",20=>"mummy");
Is an example of
Sequence array
Indexed array
Associative array
None
In php the keyword to be used before function name is
Function
Static
function
FUNCTION
function add()
{
$a=10;
echo $a;}
This is an example for
Call by value
Call by reference
None
Both
function add(&a)
{
$a=10;
echo $a;}
$a=33;
This is an example for
Call by value
Call by reference
Both of the above
None
<?php
function add()
{
global $a=10;
echo $a;
}
add();
$a+=10;
?>
Output is
10
15
20
30
$a="deepan";
$b="Deepan";
if(strcmp($a,$b))
{
echo "equal";
}
else{
echo " not equal";}
Output is
Equal
Not equal
Error
None
$a="IT is favorite department";
$b=sub_string($a,"bes",7,14);
echo $b;
Output is
IT is best department
IT is bes department
Error
IT is favorite department
HTML stands for
Hyper Text Machine Language
Hyper Text Markup Language
Hyper Technical Machine Language
None of these
Choose the correct option About HTML elements
Elements in HTML describes the way of presenting the content in the browser.
All elements must have atleast one attribute associated with it.
Element names are case in-sensitive
None of the above
Which one of the following is a form element?
text box.
radio button.
submit button.
All of these.
Which one of the following is incorrect?
<label> tag in HTML is used for creating a tag for form elements.
id attribute is used with <label> to reduce the clickable area of form elements
<label> can be used to increase the clickable area of buttons
none of the above
Choose the correct option.
Default method in HTML is GET or POST
Use of method attribute determines by which method the datas in the form will be submitted.
Method can be POST or GET.
Default method in HTML is GET.
Which of the following tag is used for drop down list?
<dropdown>
<select>
<option>
<salect>
Fill in the blanks with a suitable option in order to number items of an ordered list with small roman numbers.
<!DOCTYPE html>
<html>
<body>
<ol (a) >
<li>
Physics
</li>
<li>
Chemistry
</li>
<li>
Mathematics
</li>
</ol>
</body>
</html>
What is the default item marker in ordered lists of HTML?
Circle
Marker
disc
None of the above
Which one of the following can be used to define the spacing between the cells of a table?
border-spacing
spacing
cellspacing
table-spacing
How to insert a background image in HTML?
<body background = "img.png">
<img background = "img.png">
<body style="background-image: url();">
None of the above.
Which HTML tag is used to display the power in expression, i.e., (x2 - y2)?
<sub>
<sup>
<p>
None of the above
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
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
What is the output of the PHP code.
<?php
if(-5) {
print("Germany\n");
}
if(' ')
{ print("Texas\n"); }
printf("ZING");
?>
ZING
Germany ZING
Germany Texas ZING
error
PHP is a____________side scripting language
server
browser
client
PHP stands for
Hypertext processor
Homepage processor
Hypertext preprocessor
Who is known as father of PHP
Rasmus Lerdorf
Brendan Eich
Hakon Wium Lie
Which of the following is not true?
PHP can be used to develop web applications.
PHP makes a website dynamic
PHP can not be embedded into html.
PHP scripts are enclosed within ___
<php> . . . </php>
<?php . . . ?>
?php . . . ?php
Variables used in php
$a=5;
var a=5;
int a=5;
_______ is a concatenation operator in php
+ (plus)
+=
. (dot)
Find the output
<?php
$x = 5;
{ $x = 10;
echo $x;
}
echo $x;
?>
105
510
1010
find the output
<?php
$x = 1;
$x += 1;
echo $x;
?>
2
1
0
Insert the missing part of the code below to output "Hello World".
echo and print
System.out.println
println
cout
Write the correct opening tag and close tag for PHP scripts.
{}
<?php ?>
<>
<? ?>
Statements in PHP have to end with a special character, which one?
.
,
:
;
Create a variable in php assign with the
String
const
let
$
Get the length of the string "Hello World!".
Leng
substring
strlen
len
Use the correct function to output the number of items in an array.
$fruits = array("Apple", "Banana", "Orange");
echo $fruits[0]
echo $fruits["Apple"]
echo count($fruits)
echo $fruits[0][1]
Write a correct syntax to include a file named "footer.php".
include ("footer.php");
import("footer.php");
required("footer.php");
export("footer.php");
Assume we have a file named "webdict.txt", write the correct syntax to open and read the file content.
readfile("webdict.txt")
openfile("webdict.txt")
writefile("webdict.txt")
modifyfile("webdict.txt")
Create a session variable named "favcolor".
$session["favcolor"] = "green";
$_SESSION["favcolor"] = "green";
$_SESSION["favcolor"] ["green"];
$SESSION["favcolor"] ="green";
What type of language is PHP
Client Side
Server Side
Browser Side
Web Side
PHP is executed on
The Server
The Browser
The Website
The Machine
We create re-usable code blocks by placing them inside?
Variables
Parameters
Code Blocks
Functions
Sometimes we only want certain code to execute if a condition is true. How do we test for that?
Loop
If Statement
Integer
Variable
What is a String?
Text
Number
True
Loop
What is a Boolean
It's Just Text
It's a Number
It's Just True
It's True or False
What if we want a block of code to execute several times?
Use a Variable
Use a Function
Use a Loop
Use a Leap
$colours = array("black, blue, Red, Green") - How do I access "Red" ?
$colours[0];
$colours[2];
$colours[1]
$colours[3];
How do I print out the values of the variable "name" ?
$name;
include $name;
echo $name;
echo $name
function sayMyName(name) {} ; - How do I call tat function
sayMyname();
$sayMyName;
$sayMyName();
sayMyName("John")';
What does i++ do ?
Adds the text on to the end of i
Adds i on to the end of something
Adds i on to the existing value of i
Adds 1 to the current value of iThis is a correct answer
In an IF statement we can have 2 conditions tested. Which keyword allows this?
Else
if Else
Else if
OR
$a = "Ram"; $n = "Kumar"; $fullName = $f + $n; What is the value of $fulName
RamKumar
Ram Kumar
Ram
None
$a = "Ram"; $n = "Kumar"; $fullName = $f . $n; What is the value of $fulName
RamKumar
Ram Kumar
Kumar
None
function declarations can have (a) assigned to them?
PHP server scripts are surrounded by delimiters, which?
<?php>...</?>
<&>...</&>
<script>...</script>
<?php...?>
What does PHP stand for?
PHP: Hypertext Preprocessor
Private Home Page
Personal Hypertext Processor
How do you write "Hello World" in PHP
"Hello World";
echo "Hello World";
Document.Write("Hello World");
All variables in PHP start with which symbol?
!
$
&
The PHP syntax is most similar to:
JavaScript
VBScript
Perl and C
How do you get information from a form that is submitted using the "get" method?
Request.QueryString;
Request.Form;
$_GET[];
When using the POST method, variables are displayed in the URL:
True
False
In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:
True
False
Include files must have the file extension ".inc"
False
True
What is the correct way to include the file "time.inc" ?
<?php include file="time.inc";?>
<?php include "time.inc";?>
<!-- include file="time.inc" -->
<?php include:"time.inc";?>
PHP allows you to send emails directly from a script
False
True
What is the correct way to add 1 to the $count variable?
$count++;
count++;
++count
$count =+1
What is a correct way to add a comment in PHP?
<comment>...</comment>
*\...\*
/*...*/
<!--...--->
Which one of these variables has an illegal name?
$my-Var
$myVar
$my_Var
How do you create a cookie in PHP?
setcookie()
makecookie()
createcookie()
How do you create an array in PHP?
$cars = array("Volvo","BMW","Toyota");
$cars = "Volvo","BMW","Toyota";
$cars = array["Volvo","BMW","Toyota"];
The if statement is used to execute some code only if a specified condition is true
True
False
Which operator is used to check if two values are equal and of same data type?
=
==
===
!=
Which function is used to open a file
fopen(filename, mode of opening file)
fopen(file, mode of reading file)
open(filename, mode of opening file)
none
if there is fopen function in program then there should always be
fread()_
fwrite()
fclose()
none
!feof stands for
file end of file
not file end of file
exlamatory file end of file
none
fread() reads contents of file
word by word till eof
paragraph by paragraph till end of file
line by line till eof
none
When fwrite is used on already existing file the what will happen
new contents added to previous file contents
previous file contents deleted and new contents added
error displayed
none
when you try to open a non existing file then
error
statement file not available
question should i open new file in given name popped
new file will be created in the given name
Inorder to avoid conflicts what concept is used in files
fblock()
fclock()
flock()
none
is block parameter in flock() optional
true
false
Can values got from forms in html be given to php
sometimes
yes
no
none
LOCK_EX stands for
extended lock
excess lock
exclusive lock
extrapolar lock
What is the correct output of the given code <?php
$NUM1 = 3;
$NUM2 = 4;
$NUM3 = $NUM1 ** $NUM2;
echo $NUM3;
?>
12
81
Garbage Value
None of the above
The "**" operator belongs to which category of operators?
Arithmetic operator
Logical operator
Comparison operator
Conditional operator
Which of the following are comparison operators in PHP?
A. ==
B. !=
C. ===
D. < = >
A and B
C and D
A,B and C
A,B,C and D
What is the Output:
<?php
$color= "red";
echo "$color";
echo "$COLOR";
echo "$Color";
?>
redredred
redred
red
Error
What is the Output:
<?php
$color= "red";
echo "$color";
echo "$COLOR";
echo "$Color";
?>
redredred
redred
red
Error
What is the Output?
<?php
#echo "Hello World"
echo "#Hello World";
?>
Hello World #Hello World
Hello World
#Hello World
Error
What is the Output
<?php
$color=red;
echo "$color";
?>
red
$color
No answer
Error
What is the Ouput
<?php
$color1="green";
$color2="yellow";
echo "$color1" + "$color2";
?>
greenyellow
green yellow
Error
0
<?php
$x=10;
$y=4;
$z=3;
echo ($x % ($y) + $z);
?>
5
3
0
1
What is the Output?
<?php
$four4 =4;
$three3 = 3;
$two2 = 2;
echo " $four4 + $three3 / $two2 - 1"
4.5
7
3.5
Error
Which
of the following is a disadvantage of using JavaScript?
Client-side
JavaScript does not allow the reading or writing of files.
JavaScript
can not be used for Networking applications because there is no such support
available.
JavaScript
doesn't have any multithreading or multiprocess capabilities.
All of
the above.
Which
of the following function of Array object extracts a section of an array and
returns a new array?
reverse()
shift()
slice()
some()
