Font size
WorksheetsFINAL REVISION GUIDE
Total questions: 120
Worksheet time: 3600secs
What is PHP?
Personal Home Page
Hyper Text Preprocessor
PHP Scripts are executed on
Client
Server
Current Version of PHP is
7
8
PHP is used by
Apple
App Built using in PHP
PHP is _______________scripting language
Server
Client
Syntax used to display a message "Helloworld"
display "Hello World"
echo "Hello World
A php Script starts with
?>
<?php
A php script ends with
<?php
?>
Comments in php are
executable
non-executable
Symbol for Using Comments
#
/
Comments can be used to:
Let others understand your code
Let others execute your code
Comments can be used to:
Make the program executable
Remind yourself of what you did
Symbol for multi line comment
/* - */
#
Statements in php must end with
;
:
Create a variable named txt and assign the value "Hello".
txt = "Hello";
$txt="Hello";
Symbol used to create a variable is
$
#
_______________ as containers for storing data.
variables
statements
A variable starts with the $ sign, followed by the name of the variable
True
False
A variable name must start with a letter or the underscore character
True
False
A variable name can start with a number
True
False
False
True
False
Variable names are not case-sensitive
True
False
What is the output of the code
<?php
$nvtc = "Bahrain";
echo "I love $nvtc!";
?>
I love Bahrain
I love nvtc
Data Type tells about______
Variable Name
Type of Data
A __________ is a sequence of characters
character
string
A string in enclosed between
single quote and double quotes
single quotes only
An ____________data type is a non-decimal number
integer
float
An integer must have at least one digit
True
False
An integer can have a decimal point
True
False
An integer can be either positive or negative
True
False
Example of integer is
$x = 5985;
$x = 59.85;
A _________________ is a number with a decimal point
float
integer
Example of float
$x = 10365;
$x = 10.365;
.A______________________represents two possible states: TRUE or FALSE.
boolean
string
PHP Files have extension
.html
.php
Symbol for Comments
*
//
__________________ are often used in conditional testing
booleans
strings
The PHP _____________function returns the length of a string
strlen()
str()
The PHP _____________________ function counts the number of words in a string
strlen()
str_word_count()
The PHP __________ function reverses a string.
strlen()
strrev()
The PHP _____________function searches for a specific text within a string
strsearch()
strpos()
The PHP __________________function replaces some characters with some other characters in a string.
strpos()
str_replace()
Get the length of the string "Hello World!".
echo ___________("Hello World!");
strlen
strcount
Reverse the string "Hello World!".
echo ___________("Hello World!");
strrev
strlen
.____________ are used to perform operations on variables and values.
Operators
Operands
Sum of $x and $y
$x - $y
$x + $y
Difference of $x and $y
$x + $y
$x - $y
Product of $x and $y
$x * $y
$x ** $y
Quotient of $x and $y
$x / $y
$x % $y
Remainder of $x divided by $y
$x % $y
$x / $y
Value of 9 % 2
1
4.5
Value of 9 / 2
4.5
1
x == y if y=5 then x is
0
5
x +=5, if x=1 then output of expression is
5
6
x -=5, if x=1 then output of expression is
-4
4
x *=5, if x=2 then output of expression is
2.5
10
x /=2, if x=5 then output of expression is
10
2.5
x %=2, if x=5 then output of expression is
2.5
1
Multiply 10 with 5, and output the result.
echo 10 * 5;
echo 10 / 5;
Divide 10 by 2, and output the result.
echo 10 / 2
echo 10 * 2
Symbol for checking Equality is
=
==
Symbol for checking Identical
===
==
Symbol for checking Not Equal
$x != $y
$x == $y
Symbol for checking not equal
$x == $y
$x <> $y
Returns true if $x is greater than $y
$x > $y
$x < $y
Returns true if $x is less than $y
$x > $y
$x < $y
Returns true if $x is greater than or equal to $y
$x >= $y
$x <= $y
Returns true if $x is less than or equal to $y
$x <= $y
$x >= $y
___________ statements are used to perform different actions based on different conditions.
conditional
looping
Identify the conditional statement
while
if
Identify the conditional statement
do......while
if .... else
Identify the conditional statement
switch
for
The if statement executes some code if one condition is _______
True
False
.$x=20
$y=10
if ( $x > $y)
{ echo "x is big";
}
else
{ echo "y is big";
}
y is big
x is big
.$x=20
$y=40
if ( $x > $y)
{
echo "x is big";
}
else
{
echo "y is big";
}
x is big
y is big
if.......else statement can be used to execute
True Section and False Section
Only True Section
if ....statement can be used to execute
True Section and False Section
True Section only
.$x=5;
$y=10;
if( $x >= $y)
{ echo "I won the game";
}
else
{ echo "I lost the game";
}
I won the game
I lost the game
The ____________statement is used to perform different actions based on different conditions.
switch
if
what is the output of code
<?php
$favcolor = "yellow";
switch ($favcolor) {
case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red, blue, nor green!";
}
?>
Your favorite color is Yellow
Your favorite color is neither red,blue, not green!
_______are used to execute the same block of code again and again, as long as a certain condition is true.
switch
loop
.________ loops through a block of code as long as the specified condition is true
dowhile
while
_________ loops through a block of code once, and then repeats the loop as long as the specified condition is true
do while
while
_______loops through a block of code a specified number of times
for
foreach
___________loops through a block of code for each element in an array
for
foreach
which loop checks the condition before execution
do while
while
which loop checks the condition after
do while
while
which loop does not have initialization, condition checking and increment and decrement
for
for each
The first argument in for loop is
initialization
condition checking
Second argument in for loop is
Initialization
Condition Checking
Third argument in for loop is
initialization
increment and decrement
An ________ stores multiple values in one single variable:
Array
Variable
Starting index of an array begins with
0
1
<?php
$cars = array("Volvo", "BMW", "Toyota");
?>
cars[1]
cars[0]
The _________function is used to return the length (the number of elements) of an array:
count
length
$fruits = array("Apple", "Banana", "Orange");
echo ($fruits);
echo count($fruits);
A __________array is an array containing one or more arrays.
single dimensional
multi dimensioal
what is the output statement for getting "Land Rover"
$cars = array (
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
echo $cars[3][0];
echo $cars[3][1];
What is the use of Form ?
used to submit data
used to read data
used to collect data
used to send data
A form is attribute used to send data to server page
Submit
Method
Form
Action
A method used to send data to server which is visible
Post
Get
Get and POST
Above ALL
A method which send the data whose limit is 2000 characters
Get
Post
Get and POST
Above ALL
A method which is used by most developers
Get
Post
Get and POST
Above ALL
A method which is used for sending data by hiding is
Get and POST
Above ALL
Get
Post
The Action attribute of the Tag FORM is called by
Button
Reset
All the above
Submit
The default value of the TextField is changed by using the attribute
Value
Name
ID
Text
The Style rules written inside the tag is called as
External
inline
embedded
The Style rules written inside the tag <style> tag is called as
embedded
inline
external
The Style rules written inside the (styles.css) file is called as
inline
embedded
external
Process of checking the data is called
Verification
Validation
Crosschecking
Finalizing
A php page calls itself by using the attribute
$_SERVER[PHP_SELF]
$_GET
$_POST
$REQUEST_METHOD
Regular Expressions are used for
Improves Code
Writing Expressions
Validation
Used for calculations
Code reusability is achieved using the concept of
Expressions
Variables
Arrays
Functions
The Syntax used to send an email is
mailto(mail id, subject )
mail ( mail id, subject, message)
sendmail(mail id, subject ,message)
mail ( mail id, message)
Form Elements used to check I agree to terms and conditions feature is
Radio
Submit
Check box
Reset
Form Elements used to for entering the password is
Radio
TextField
Checkbox
Password
What is the abbreviation of XSS
Cross Side Scripting
Cross site scripting
Extreme site scripting
Extreme Side Scripting
What is the Full form of CSS
Cascading Style Sheets
Cascading Simple Sheets
Cascading Server Sheets
Cascading Server Side
Functions used for Regular Expressions
preg_verify
preg_validate
preg_check
preg_match
