- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Installation
- PHP - History
- PHP - Syntax
- PHP - Hello World
- PHP - Comments
- PHP - Variables
- PHP - Echo/Print
- PHP - var_dump
- PHP - $ and $$ Variables
- PHP - Constants
- PHP - Magic Constants
- PHP - Data Types
- PHP - Type Casting
- PHP - Type Juggling
- PHP - Strings
- PHP - Boolean
- PHP - Integers
- PHP - Files & I/O
- PHP - Maths Functions
- PHP - Heredoc & Nowdoc
- PHP - Compound Types
- PHP - File Include
- PHP - Date & Time
- PHP - Scalar Type Declarations
- PHP - Return Type Declarations
- PHP Operators
- PHP - Operators
- PHP - Arithmatic Operators
- PHP - Comparison Operators
- PHP - Logical Operators
- PHP - Assignment Operators
- PHP - String Operators
- PHP - Array Operators
- PHP - Conditional Operators
- PHP - Spread Operator
- PHP - Null Coalescing Operator
- PHP - Spaceship Operator
- PHP Control Statements
- PHP - Decision Making
- PHP - If…Else Statement
- PHP - Switch Statement
- PHP - For Loop
- PHP - Foreach Loop
- PHP - While Loop
- PHP - Do…While Loop
- PHP - Break Statement
- PHP - Continue Statement
- PHP Arrays
- PHP - Arrays
- PHP - Indexed Array
- PHP - Associative Array
- PHP - Multidimensional Array
- PHP - Array Functions
- PHP - Constant Arrays
- PHP Functions
- PHP - Functions
- PHP - Function Parameters
- PHP - Call by value
- PHP - Call by Reference
- PHP - Default Arguments
- PHP - Named Arguments
- PHP - Variable Arguments
- PHP - Returning Values
- PHP - Passing Functions
- PHP - Recursive Functions
- PHP - Type Hints
- PHP - Variable Scope
- PHP - Strict Typing
- PHP - Anonymous Functions
- PHP - Arrow Functions
- PHP - Variable Functions
- PHP - Local Variables
- PHP - Global Variables
- PHP Superglobals
- PHP - Superglobals
- PHP - $GLOBALS
- PHP - $_SERVER
- PHP - $_REQUEST
- PHP - $_POST
- PHP - $_GET
- PHP - $_FILES
- PHP - $_ENV
- PHP - $_COOKIE
- PHP - $_SESSION
- PHP File Handling
- PHP - File Handling
- PHP - Open File
- PHP - Read File
- PHP - Write File
- PHP - File Existence
- PHP - Download File
- PHP - Copy File
- PHP - Append File
- PHP - Delete File
- PHP - Handle CSV File
- PHP - File Permissions
- PHP - Create Directory
- PHP - Listing Files
- Object Oriented PHP
- PHP - Object Oriented Programming
- PHP - Classes and Objects
- PHP - Constructor and Destructor
- PHP - Access Modifiers
- PHP - Inheritance
- PHP - Class Constants
- PHP - Abstract Classes
- PHP - Interfaces
- PHP - Traits
- PHP - Static Methods
- PHP - Static Properties
- PHP - Namespaces
- PHP - Object Iteration
- PHP - Encapsulation
- PHP - Final Keyword
- PHP - Overloading
- PHP - Cloning Objects
- PHP - Anonymous Classes
- PHP Web Development
- PHP - Web Concepts
- PHP - Form Handling
- PHP - Form Validation
- PHP - Form Email/URL
- PHP - Complete Form
- PHP - File Inclusion
- PHP - GET & POST
- PHP - File Uploading
- PHP - Cookies
- PHP - Sessions
- PHP - Session Options
- PHP - Sending Emails
- PHP - Sanitize Input
- PHP - Post-Redirect-Get (PRG)
- PHP - Flash Messages
- PHP AJAX
- PHP - AJAX Introduction
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML
- PHP - XML Introduction
- PHP - Simple XML Parser
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Login Example
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP Advanced
- PHP - MySQL
- PHP.INI File Configuration
- PHP - Array Destructuring
- PHP - Coding Standard
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Try…Catch
- PHP - Bugs Debugging
- PHP - For C Developers
- PHP - For PERL Developers
- PHP - Frameworks
- PHP - Core PHP vs Frame Works
- PHP - Design Patterns
- PHP - Filters
- PHP - JSON
- PHP - Exceptions
- PHP - Special Types
- PHP - Hashing
- PHP - Encryption
- PHP - is_null() Function
- PHP - System Calls
- PHP - HTTP Authentication
- PHP - Swapping Variables
- PHP - Closure::call()
- PHP - Filtered unserialize()
- PHP - IntlChar
- PHP - CSPRNG
- PHP - Expectations
- PHP - Use Statement
- PHP - Integer Division
- PHP - Deprecated Features
- PHP - Removed Extensions & SAPIs
- PHP - PEAR
- PHP - CSRF
- PHP - FastCGI Process
- PHP - PDO Extension
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
PHP Mock Test
This section presents you various set of Mock Tests related to PHP. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
PHP Mock Test III
Q 1 - Which of the following function returns selected parts of an array?
Answer : D
Explanation
array_slice() − Returns selected parts of an array.
Q 2 - Which of the following function returns the sum of the values in an array?
Answer : A
Explanation
array_sum() − Returns the sum of the values in an array.
Q 3 - Which of the following function checks if a specified value exists in an array?
Answer : B
Explanation
in_array() − Checks if a specified value exists in an array.
Q 4 - Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences.
Answer : A
Explanation
Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences.
Q 5 - Doubly quoted strings are treated almost literally, whereas singly quoted strings replace variables with their values as well as specially interpreting certain character sequences.
Answer : B
Explanation
Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences.
Q 6 - How will you concatenate two strings?
Answer : A
Explanation
To concatenate two string variables together, use the dot (.) operator.
Q 7 - If there is any problem in loading a file then the require() function generates a warning but the script will continue execution.
Answer : B
Explanation
If there is any problem in loading a file then the require() function generates a fatal error and halt the execution of the script.
Q 8 - If there is any problem in loading a file then the include() function generates a warning but the script will continue execution.
Answer : A
Explanation
If there is any problem in loading a file then the include() function generates a warning but the script will continue execution.
Q 9 - Which of the following function opens a file?
Answer : A
Explanation
The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate.
Q 10 - Which of the following function is used to read the content of a file?
Answer : B
Explanation
Once a file is opened using fopen() function it can be read with a function called fread(). This function requires two arguments. These must be the file pointer and the length of the file expressed in bytes.
Q 11 - Which of the following function is used to get the size of a file?
Answer : C
Explanation
The files's length can be found using the filesize() function which takes the file name as its argument and returns the size of the file expressed in bytes.
Q 12 - Which of the following function is used to check if a file exists or not?
Answer : D
Explanation
File's existence can be confirmed using file_exist() function which takes file name as an argument.
Answer : A
Explanation
Yes! You can set a parameter to have a default value if the function's caller doesn't pass it.
Q 14 - Which of the following is used to set cookies?
Answer : A
Explanation
PHP provided setcookie() function to set a cookie.
Q 15 - Which of the following is used to get cookies?
Answer : B
Explanation
PHP provides many ways to access cookies. Simplest way is to use either $_COOKIE or $HTTP_COOKIE_VARS variables.
Q 16 - Which of the following is used to check that a cookie is set or not?
Answer : C
Explanation
You can use isset() function to check if a cookie is set or not.
Q 17 - Which of the following is used to delete a cookie?
Answer : A
Explanation
To delete a cookie you should call setcookie() with the name argument only.
Q 18 - Which of the following is used to create a session?
Answer : A
Explanation
A PHP session is easily started by making a call to the session_start() function.
Q 19 - Which of the following is used to access session variables in PHP?
Answer : B
Explanation
Session variables are stored in associative array called $_SESSION[]. These variables can be accessed during lifetime of a session.
Q 20 - Which of the following is used to check if session variable is already set or not in PHP?
Answer : C
Explanation
Make use of isset() function to check if session variable is already set or not.
Q 21 - Which of the following is used to destroy the session?
Answer : D
Explanation
A PHP session can be destroyed by session_destroy() function.
Q 22 - Which of the following provides access to the uploaded file in the temporary directory on the web server?
Answer : A
Explanation
$_FILES['file']['tmp_name'] − it provides access to the uploaded file in the temporary directory on the web server.
Q 23 - Which of the following provides the actual name of the uploaded file?
Answer : B
Explanation
$_FILES['file']['name'] − it provides the actual name of the uploaded file.
Q 24 - Which of the following provides the size of the uploaded file in PHP?
Answer : C
Explanation
$_FILES['file']['size'] − it provides the size of the uploaded file in PHP.
Q 25 - Which of the following provides content type of the uploaded file in PHP?
Answer : D
Explanation
$_FILES['file']['type'] − it provides the content type of the uploaded file in PHP.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | D |
2 | A |
3 | B |
4 | A |
5 | B |
6 | A |
7 | B |
8 | A |
9 | A |
10 | B |
11 | C |
12 | D |
13 | A |
14 | A |
15 | B |
16 | C |
17 | A |
18 | A |
19 | B |
20 | C |
21 | D |
22 | A |
23 | B |
24 | C |
25 | D |