Font size
WorksheetsIntroduction to PHP
Total questions: 60
Worksheet time: 45mins
Which tag is used for php
<?php
?>
<style>
<php ?>
<php
/php>
What are the types of array in php
Indexed, sequence
Associative, sequence
Indexed, associative
None
In php the keyword to be used before function name is
Function
Static
function
FUNCTION
HTML stands for
Hyper Text Machine Language
Hyper Text Markup Language
Hyper Technical Machine Language
None of these
Which one of the following is a form element?
text box.
radio button.
submit button.
All of these.
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 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 store small snippets of information inside what?
Functions
Loops
If Statements
Variables
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 integer?
It's a Whole Number
It's a Decimal Number
It's a True or False Declaration
It's a String of Text
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
What type of variable is this: $isMale = false;
Integer
Boolean
String
char
In an IF statement we can have 2 conditions tested. Which keyword allows this?
Else
if Else
Else if
OR
$a = 4 ; $b = 6; $c = $a + $b; What is the value of variable "c" ?
6
8
10
None
$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 calls can have____________ inside them.
Parameters
Arguments
Variables
Types
PHP is a ............
Open Source Language
Widely Used Language
Server side scripting language
All of the above
Which of the following symbol is used to add multiple line comments in PHP ?
//
/* */
{{ }}
{/ \}
How to define a function in PHP?
function {function body}
function functionName(parameters) {function body}
functionName(parameters) {function body}
None of the above
Which of the following is used for concatenation in PHP?
+ (plus)
* (Asterisk)
. (dot)
append()
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;
Which of the following is the correct way to create an array in PHP?
$season = array["summer" , "winter" , "spring" , "autumn"];
$season = array("summer" , "winter" , "spring" , "autumn");
$season =( "summer" , "winter" , "spring" , "autumn");
All of the above
What will be the output of the following program?
<?php
$a = 15;
function show() {
$a = 20; echo "$a";
}
show();
echo "$a";
?>
2020
2015
1515
0
Insert the missing part of the code below to output "Hello World".
echo and print
System.out.println
println
cout
Statements in PHP have to end with a special character, which one?
.
,
:
;
Create a variable in php assign with the
String
const
let
$
What does PHP stands for?
PHP: Hypertext Preprocessor
Private Home Page
Personal Hypertext Processor
The if statement is used to execute some code only if a specified condition is true
True
False
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
My first PHP page
Hello World!
Hello World!
My first PHP page
echo "Hello World!";
<!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
The Result..?
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
PHP is free to download and use
False
True
PHP files can contain text, HTML, CSS, JavaScript, and PHP code
True
False
<!DOCTYPE html>
<html>
<body>
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
the result..?
My car is red
My house is
My boat is
My car is red
My house is
My car is red
<!DOCTYPE html>
<html>
<body>
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
echo $txt;
echo "<br>";
echo $x;
echo "<br>";
echo $y;
?>
</body>
</html>
the result..?
Hello world!
5
10.5
Hello world!
5
10.5
How do you create an array in PHP?
$cars = array("Volvo","BMW","Toyota");
$cars = "Volvo","BMW","Toyota";
$cars = array["Volvo","BMW","Toyota"];
Which operator is used to check if two values are equal and of same data type?
=
==
===
!=
A server-side scripting language designed for web development is ...
HTML
PHP
C++
C#
The script is used to display the output of parameters that are passed to it is ...
ECHO
SELECT
INSERT
Comments in PHP are written with ...
$
//
<!-- ... -->
" ... "
The correct way to print out the values of the variable "name" is ...
$name;
include $name;
echo $name;
echo $name
<?php
$number = 20;
if($number < 10){
echo "SMA ABBS";
}else{
$sum = $number + 10;
echo "$sum";
}
?>
The output is ...
SMA ABBS
20
30
Error
The "**" operator belongs to which category of operators?
Arithmetic operator
Logical operator
Comparison operator
Conditional operator
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
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";
?>
red
$color
No answer
Error
A
function name cannot start with a ____
alphabet
underscore
number
Both C
and B
HTML
page can be access using _______ protocol.
HTTP
FTP
SMTP
POP
Which among the following is NOT a type of loops?
if
for
while
do while
Which among the following is NOT type of array
Unindexed
Indexed
Associative
Multidimensional
6.
In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings. Is this statement TRUE or FALSE?
TRUE
FALSE
