- 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 II
Q 1 - Which of the following is correct about constants vs variables in PHP?
Answer : C
Explanation
Both of the above options are correct.
Q 2 - Which of the following is correct about constants vs variables in PHP?
A - Constants may be defined and accessed anywhere without regard to variable scoping rules.
B - Once the Constants have been set, may not be redefined or undefined.
Answer : C
Explanation
Both of the above options are correct.
Q 3 - Which of the following magic constant of PHP returns current line number of the file?
Answer : A
Explanation
_LINE_ − The current line number of the file.
Q 4 - Which of the following magic constant of PHP returns full path and filename of the file?
Answer : B
Explanation
_FILE_ − The full path and filename of the file. If used inside an include,the name of the included file is returned. Since PHP 4.0.2, _FILE_ always contains an absolute path whereas in older versions it contained relative path under some circumstances.
Q 5 - Which of the following magic constant of PHP returns function name?
Answer : C
Explanation
_FUNCTION_ − The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
Q 6 - Which of the following magic constant of PHP returns class name?
Answer : D
Explanation
_CLASS_ − The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
Q 7 - Which of the following magic constant of PHP returns class method name?
Answer : A
Explanation
_METHOD_ − The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).
Q 8 - Which of the following keyword terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch?
Answer : A
Explanation
break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.
Q 9 - Which of the following keyword causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating?
Answer : B
Explanation
continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
Q 10 - Which of the following array represents an array with a numeric index?
Answer : A
Explanation
Numeric array − An array with a numeric index. Values are stored and accessed in linear fashion.
Q 11 - Which of the following array represents an array with strings as index?
Answer : B
Explanation
Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.
Q 12 - Which of the following array represents an array containing one or more arrays?
Answer : C
Explanation
Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices.
Q 13 - Which of the following operator is used to concatenate two strings?
Answer : A
Explanation
To concatenate two string variables together, use the dot (.) operator.
Q 14 - Which of the following function is used to get length of a string?
Answer : B
Explanation
The strlen() function is used to find the length of a string.
Q 15 - Which of the following function is used to locate a string within a string?
Answer : C
Explanation
The strpos() function is used to search for a string or character within a string.
Q 16 - Which of the following function is used to get environment variables in PHP?
Answer : D
Explanation
PHP provides a function getenv() to access the value of all the environment variables.
Q 17 - Which of the following variable is used to get user's browser and operating system details in PHP?
Answer : A
Explanation
One of the environemnt variables set by PHP is HTTP_USER_AGENT which identifies the user's browser and operating system.
Q 18 - Which of the following variable is used to generate random numbers using PHP?
Answer : B
Explanation
The PHP rand() function is used to generate a random number. This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated. This is achieved using the srand() function that specifiies the seed number as its argument.
Q 19 - Which of the following variable is used for the PHP script name?
Answer : A
Explanation
The PHP default variable $_PHP_SELF is used for the PHP script name and when you click "submit" button then same PHP script will be called.
Q 20 - Which of the following function sorts an array in reverse order?
Answer : A
Explanation
rsort() − Sorts an array in reverse order.
Q 21 - Which of the following function is used to redirect a page?
Answer : B
Explanation
The PHP header() function supplies raw HTTP headers to the browser and can be used to redirect it to another location. The redirection script should be at the very top of the page to prevent any other part of the page from loading.
Q 22 - Which of the following is used to get information sent via get method in PHP?
Answer : A
Explanation
The PHP provides $_GET associative array to access all the sent information using GET method.
Q 23 - Which of the following can be used to get information sent via get/post method in PHP?
Answer : A
Explanation
The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
Q 24 - Which of the following function creates an array?
Answer : A
Explanation
array() − Creates an array.
Q 25 - Which of the following function can be used to get an array in the reverse order?
Answer : A
Explanation
array_reverse() − Returns an array in the reverse order.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | C |
2 | C |
3 | A |
4 | B |
5 | C |
6 | D |
7 | A |
8 | A |
9 | B |
10 | A |
11 | B |
12 | C |
13 | A |
14 | B |
15 | C |
16 | D |
17 | A |
18 | B |
19 | A |
20 | A |
21 | B |
22 | A |
23 | A |
24 | A |
25 | A |