NEW
Font size
WorksheetsServer Side Scripting (PHP)
Total questions: 30
Worksheet time: 30mins
What is PHP?
A widely-used open source general-purpose scripting language.
A type of database.
A web server software.
A programming language for mobile apps.
What are the features of PHP?
Easy to learn and runs efficiently.
Requires complex setup.
Not compatible with any server.
Is a paid software.
What does PHP stand for?
Hypertext Preprocessor
Personal Home Page
Private Hypertext Page
Public Hypertext Preprocessor
What is the output of the following PHP code: echo 'Hello World!';
Hello World!
Hello World
Hello
World!
What is the significance of the $ sign in PHP?
It indicates a variable.
It indicates a function.
It indicates a constant.
It indicates an array.
What is the purpose of the echo statement in PHP?
To output text to the screen.
To declare a variable.
To create a function.
To include a file.
What is the correct file extension for PHP files?
.php
.html
.txt
.xml
What is a variable in PHP?
A symbol that stands for a value.
A type of function.
A type of array.
A type of database.
What does it mean that PHP is a loosely typed language?
Variables do not need to be declared with a data type.
All variables must be declared with a data type.
Variables can only hold one type of data.
Variables must be declared before use.
What must a variable name start with?
A letter or underscore
A number
A special character
What are the three different variable scopes in PHP?
Local, global, static
Public, private, protected
Instance, class, static
What does the var_dump() method do?
Checks the data type of a variable
Outputs the length of a string
Counts the number of words in a string
What is the syntax for a for loop in PHP?
for(initialisation; condition; incrementation)
for(condition; initialisation; incrementation)
for(incrementation; condition; initialisation)
What does the strlen() function do?
Returns the length of a string
Counts the number of words in a string
Reverses a string
What does the strrev() function do?
Returns the length of a string
Counts the number of words in a string
Reverses a string
Counts the reversed string
What is an associative array in PHP?
An array with named keys
An array with numeric indices
An array containing other arrays
What is the syntax for declaring a user-defined function in PHP?
function functionName() { code to be executed; }
functionName() { code to be executed; }
function functionName { code to be executed; }
function functionName() { code executed; }
What is the purpose of the return statement in a function?
To end the function
To return a value from the function
To call another function
To declare a variable
What does the $_POST superglobal do?
Collects form data sent via HTTP POST method
Collects form data sent via URL parameters
Stores session data
Handles file uploads
What is the difference between GET and POST methods?
GET is visible in the URL, POST is not
POST has limits on data size, GET does not
GET is used for sensitive data, POST is not
There is no difference
What is the purpose of the PHP Data Object (PDO)?
To connect PHP code with any database server.
To create HTML pages.
To manage user sessions.
To store cookies.
What does the isset() method do in PHP?
Checks if a variable has a value.
Creates a new variable.
Deletes a variable.
Displays a variable.
What is a cookie in PHP?
A small text file sent to the user's computer.
A method to store user sessions.
A type of database.
A programming error.
What is the purpose of sessions in PHP?
To store user information on the server.
To track user activities.
To manage cookies.
To connect to a database.
What does the fetchAll() method do?
Gets all records from a table.
Inserts a new record into a table.
Deletes a record from a table.
Updates a record in a table.
What is the correct way to create a database connection in PHP?
$conn = new PDO($servername, $username, $password);
$conn = new Database($servername, $username, $password);
$conn = connect($servername, $username, $password);
$conn = new Connection($servername, $username, $password);
What is the purpose of the $_POST superglobal in PHP?
To collect form data submitted via HTTP POST method.
To collect URL parameters.
To store session data.
To manage cookies.
What is the significance of the '->' operator in PDO?
It is used to execute SQL statements.
It is used to create a new PDO object.
It is used to connect to a database.
It is used to fetch records.
What is the difference between GET and POST methods in PHP?
GET has limits on the amount of information to send, while POST does not.
POST is visible to everyone, while GET is not.
GET is used for sensitive information, while POST is not.
There is no difference.
What does the mysqli_connect() function do?
Establishes a connection to a MySQL database.
Executes a SQL query.
Fetches data from a database.
Closes a database connection.
