NEW
Font size
WorksheetsITEAPV - Midterm Exam
Total questions: 70
Worksheet time: 35mins
What does PHP stand for?
Preprocessor Hypertext Page
Personal Home Page
Hypertext Transfer Protocol
PHP Hypertext Preprocessor
PHP is considered a server-side scripting language.
True
False
Maybe
I don't know
Which of the following extension is correct for PHP files?
.html
.opp
.php
.pxp
How do you start the PHP scripting block?
<php.....?>
<script .... script>
<?php.... ?php>
<?......?php>
Whitespace is not ignored in PHP?
True
False
Maybe
I don't know
Variables in PHP always begins with...
?
&
$
#
Which of the following is the correct syntax to start a multiple line comment in PHP?
#-----------#
/______/
/*--------*/
/------/*
Which of the following is the correct syntax to declare a variable in PHP?
var = 10;
$var = "10";
$10 = var;
$var = 10
How do you display "Hello World" in PHP?
Hello World;
echo Hello World;
echo (Hello World);
echo "Hello World";
What does a semicolon indicate in PHP?
The end of a PHP statement or instruction.
The start of PHP statement or instruction.
The start of a PHP script block.
The end of the a PHP script block.
In PHP, statements may be written in either upper or lowercase. Echo, echo, and ECHO are all the same.
True
False
What is the value of $num if the following code is to consider?
$varName = "num";
$num = 25;
$$varName = 75;
value
25
75
None of the Above
How do you get information from a form that is submitted using the "get" method?
Request.QueryString;
$_GET[];
Request.Form;
What is the correct way to add 1 to the $count variable?
$count =+1
$count++;
++count
count++;
Which one of these variables has an illegal name?
$my-Var
$myVar
$my_Var
How do you create an array in PHP?
$cars = "Volvo", "BMW", "Toyota";
$cars = array["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
When concatenating strings, you use what symbol in PHP?
A comma ,
A plus sign +
a hyphen -
a full stop .
Which will input data into a table?
INSERT INTO table(name, height, weight) VALUES('strand', '6ft 2in', '165')
INPUT INTO table(name, height, weight) VALUES('strand', '6ft 2in', '165')
INSERT INTO table CATEGORIES(name, height, weight) VALUES('strand', '6ft 2in', '165')
INSERT INTO table CATEGORIES(name, height, weight) ('strand', '6ft 2in', '165')
If I want to show all data in a MySQL table, I would use
SHOW * FROM table;
SELECT * FROM table;
SHOW * IN table;
SELECT * IN table;
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 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
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
Find the output
<?php
$x = 5;
$y= 10;
echo $x;
echo $y;
?>
105
510
5
10
10
5
$a = 4 ; $b = 6; $c = $a + $b; What is the value of variable "c" ?
6
8
10
None
The * operator belongs to which category of operators?
Arithmetic operator
Logical operator
Comparison operator
Conditional operator
What is the Output
<?php
$color=red;
echo "$color";
?>
red
$color
No answer
Error
PHP is a ............
Open Source Language
Widely Used Language
Server side scripting language
All of the above
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);
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
What will be the output of the following program?
<?php
$var1 = "Hello";
$var2 = "World";
echo "$var1$var2";
?>
HelloWorld
Hello World
"$var1$var2"
None of the above
<?php
$sum= 15+30;
echo "$sum";
?>
The Correct output is ...
Error
15+30
45
No Answer
<?php
for ($x=1; $x<=10; $x++){
echo "$x ";
}
?>
the output is ...
1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
5 6 7 8 9 10
No answer
PHP Scripts are executed using
XAMPP
JAVA
EDITOR
NONE
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
Why is validation important in web development?
To improve the visual design of web pages.
To ensure that the user input meets the specified criteria and is safe to process.
To increase the loading speed of the website.
To store data in the database.
What is the primary role of a database in web applications?
To generate HTML and CSS code.
To authenticate users logging into the system.
To store, retrieve, and manage data efficiently.
To process and execute client-side scripts.
Why do you need a database connection in PHP?
To link CSS files to HTML.
To enable communication between PHP scripts and the database.
To write JavaScript code.
To validate user input.
What is the purpose of the INSERT statement in SQL?
To create new tables in the database.
To modify the structure of the database.
To add new records to a table.
To change the credentials of the database user.
What would you typically use to view and retrieve data from a database in a PHP application?
INSERT SQL command.
CSS selectors.
SELECT SQL query.
PHP echo statement alone.
In the context of web applications, what is the difference between editing and updating?
Editing refers to changing the content on the website, and updating refers to reloading the page.
Editing involves modifying data in the database, while updating refers to the process of saving those changes.
Editing is done on the client side, while updating is a server-side operation.
There is no difference; both terms mean the same thing.
What does the DELETE statement do in SQL?
Deletes the entire database.
Removes specific records from a table based on a condition.
Deletes the structure of the table.
Clears the data from a form.
In PHP, when would you use a foreach loop?
To execute a block of code a set number of times.
To loop through each key/value pair in an array.
To check the validity of user input.
To connect to a database.
What is a common method to implement a search feature in a PHP application?
Using a WHILE loop to iterate through all elements of a page.
Using a SELECT query with a WHERE clause to filter results from a database.
Using the INSERT command to add search terms to the database.
Using CSS to hide non-matching elements on a page.
What is the primary purpose of implementing a login feature in a web application?
To collect user emails.
To provide users with the ability to customize the website's theme.
To restrict access to certain parts of the application to authenticated users.
To store user preferences for the layout of the web pages.
In PHP, what is the purpose of using sessions?
To improve the website's SEO.
To permanently store user information on the server.
To maintain information across different pages during a user's visit to a website.
To create new users in the database.
What does the isset() function check for when dealing with form buttons in PHP?
If a variable has a value that is not NULL.
If the button has been clicked or not.
If a session has been started.
If a button exists in the HTML form.
What is the purpose of .htaccess files on web servers?
To store HTML templates for the website.
To configure server settings, like URL redirection and access control for directories.
To create backup copies of website files.
To store JavaScript variables.
What does the term "navigation technique" refer to in web design?
The method used to move data from server to client.
The algorithm used to sort database entries.
The strategy for moving between different webpages or sections on a website.
The process of uploading files to the server.
An "upgraded session" mechanism in PHP could include what?
Shorter session times for better performance.
Use of session variables to maintain stateful information across multiple pages with enhanced security measures.
The elimination of sessions in favor of cookies only.
Storing all user data in session variables to avoid database use.
What is the primary consideration when implementing a file upload feature in a web application?
Allowing all file types to be uploaded without restrictions.
Ensuring that uploaded files do not exceed the maximum server capacity.
Security measures to prevent the upload of malicious files.
Ensuring the uploaded files are publicly accessible for all users.
In a web form, how is a checkbox typically used?
To allow users to select only one option from a set of mutually exclusive options.
To submit the form automatically without clicking a submit button.
To allow users to select multiple options from a set of choices.
To display a dropdown list of options for users to choose from.
