Font size
WorksheetsPHP Basics
Total questions: 54
Worksheet time: 54mins
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
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
PHP Scripts are executed using
XAMPP
JAVA
EDITOR
NONE
Arrays are created using
Arrays()
array()
aray()
array[]
Where is your PHP project file located?
C:\xampp\htdocs\
C:\xampp\project\
D:\xampp\htdocs\
The 2 basic ways to get output in PHP are __________.
echo and cout
echo and scan
echo and print
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;
$a = 4 ; $b = 6; $c = $a + $b; What is the value of variable "c" ?
6
8
10
None
How do you get information from a form that is submitted using the "get" method?
Request.QueryString;
$_GET[];
Request.Form;
Which one of the following is the right way of defining a function in PHP?
function { function body }
data type functionName(parameters) { function body }
functionName(parameters) { function body }
function functionName(parameters) { function body }
Associative arrays are a ____ pair data structure.
Single value
Key value
Double value
String value
Which of the following is used to delete a cookie?
setcookie() function
$_COOKIE variable
isset() function
unsetcookie() function
$colours = array("black, blue, Red, Green") - How do I access "Red" ?
$colours[0];
$colours[2];
$colours[1]
$colours[3];
$a=array("Timmy","Jimmy");
Is an example of
Indexed array
Associative array
Sequence array
None
What does X mean in XAMPP?
Cross Form Operating System
Cross Combination of PHP and MySQL
Cross Platform Operating System
Cross Programming Languange used
What is the standard format for declaring variables in PHP?
Variable names must start with a dollar sign followed by a character and a letter and must not contain spaces
Declaring a variable must start with a dollar sign, the variable name must start with a letter followed by other characters, and must not contain any spaces.
Declaring a variable must start with a dollar sign, and the variable name must start with a letter followed by other characters and contain any spaces.
Declaring a variable must start with a dollar sign, the variable name must start with followed by a character and a leter and it must contain any spaces.
What conditional statement that is used to perform different actions based on different conditions and to avoid long block of if-else-if else conditional statement?
PHP if() Statement
PHP if-else() statement
PHP if-else-if() statement
Switch Case statement
What are the appropriate PHP cides for instantiating an indexed array in PHP with the given list?
List of the electronic Brands
-HP
-Acer
-Apple
-Dell
$e brands=array("HP"."Acer"."Apple"."Dell");
$ebrands=array("HP","Acer"."Apple","Dell");
$ ebrands=array("HP","Acer","Apple","Dell");
$ebrands=array("HP","Acer","Apple","Dell");
What are the appropriate PHP codes to display the Banana in the given array?
<?php $fruits = array("Apple", "Banana", "Orange"); ?>
Echo $fruits[2];
echo $fruits[1]:
echo $fruits[1];
echo $fruit[2];
Which one of the following statements is used to create a table?
CREATE TABLE table_name (column_type column_name);
CREATE table_name (column_type column_name);
CREATE TABLE table_name (column_name column_type);
CREATE table_name (column_name column_type);
Which of the following is the use of strlen() function in PHP?
The strlen() function returns both value and type of string
The strlen() function returns the length of string
The strlen() function returns the type of string
The strlen() function returns the value of string
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
Which of the following function converts a string to all uppercase?
upper()
strtoupper()
struppercase()
uppercase()
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 if we want a block of code to execute several times?
Use a Variable
Use a Function
Use a Loop
Use a Leap
Which method is more secure send the data to server
post
get
request
none
<?php $fruits = array ("apple", "orange", array ("pear", "mango"),"banana");
echo (count($fruits, 1)); ?>
What is the output of the php code?
5
4
6
3
Which superglobal variable holds information about headers, paths, and script locations?
$GLOBALS
$_GET
$_SERVER
$_SESSION
What is the output?
<?php
define(GREETING, " PHP is a Scripting Language");
echo "$GREETING;
?>
$GREETING
no output
GREETING
PHP is a Scripting Language
<?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
What is the Output:
<?php
$color= "red";
echo "$color";
echo "$COLOR";
echo "$Color";
?>
redredred
redred
red
Error
What will be the value of $result after the following code executes?
$x = 5;
$y = 3;
$result = ($x > 2) && ($y < 10);
true
false
error
What are the two types of array in php
Indexed, sequence
Associative, sequence
Indexed, associative
None
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
Which one of the following is a form element?
text box.
radio button.
submit button.
All of these.
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]
What is the output of the following PHP code?
<?php
$num = 10;
function multiply() {
$num = 5;
return $num * 2;
}
echo $num + multiply();
?>
20
25
30
Which PHP function is used to check if a variable is an array or not?
is_array()
check_array()
validate_array()
What will be the output of the following PHP code?
<?php
$str = "Hello World!";
echo strrev($str);
?>
Hello World!
!dlroW olleH
dlroW olleH!
Your full name
Your Reg No
Your Campus ID
Course (MCA or MSc)
How would you rate the difficulty level of the quiz?
Easy
Moderate
Difficult
Very difficult
Were you able to complete the quiz within the given time frame?
Yes, easily
Yes, but it was challenging
No, ran out of time
Did not attempt within the time frame
Any suggestions for improving future quizzes or study materials?
