- 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 IV
Q 1 - Which of the following provides the error code associated with this file upload?
Answer : A
Explanation
$_FILES['file']['error'] − it provides the error code associated with this file upload.
Q 2 - Which of the following contains a reference to every variable which is currently available within the global scope of the script?
Answer : A
Explanation
$GLOBALS − Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables.
Q 3 - Which of the following is an array containing information such as headers, paths, and script locations?
Answer : B
Explanation
$_SERVER − This is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these. See next section for a complete list of all the SERVER variables.
Q 4 - Which of the following is an associative array of variables passed to the current script via HTTP cookies?
Answer : C
Explanation
$_COOKIE − An associative array of variables passed to the current script via HTTP cookies.
Q 5 - Which of the following is an associative array containing session variables available to the current script?
Answer : D
Explanation
$_SESSION − An associative array containing session variables available to the current script.
Q 6 - Which of the following gives a string containing PHP script file name in which it is called?
Answer : A
Explanation
$_PHP_SELF − A string containing PHP script file name in which it is called.
Q 7 - Which of the following is correct about ereg() function?
Answer : A
Explanation
The ereg() function searches a string specified by string for a string specified by pattern, returning true if the pattern is found, and false otherwise.
Q 8 - Which of the following is correct about eregi() function?
Answer : B
Explanation
The eregi() function searches throughout a string specified by pattern for a string specified by string. The search is not case sensitive.
Q 9 - Which of the following is correct about preg_match() function?
Answer : C
Explanation
The preg_match() function searches string for pattern, returning true if pattern exists, and false otherwise.
Q 10 - Which of the following method of Exception class retrieve the error message when error occured?
Answer : A
Explanation
getMessage() method of Exception class returns the message of exception.
Q 11 - Which of the following method of Exception class returns the code of exception when error occured?
Answer : B
Explanation
getCode() method of Exception class returns the code of exception.
Q 12 - Which of the following method of Exception class returns source filename?
Answer : C
Explanation
getFile() method of Exception class returns source filename.
Q 13 - Which of the following method of Exception class returns source line?
Answer : D
Explanation
getLine() method of Exception class returns source line.
Q 14 - Which of the following method of Exception class returns array of the backtrace?
Answer : C
Explanation
getTrace() method of Exception class returns array of the backtrace.
Q 15 - Which of the following method of Exception class returns formated string of trace?
Answer : D
Explanation
getTraceAsString() method of Exception class returns formated string of trace.
Q 16 - Which of the following method returns current date and time?
Answer : A
Explanation
PHP's time() function gives you all the information that you need about the current date and time. It requires no arguments but returns an integer.
Q 17 - Which of the following method returns a formatted string representing a date?
Answer : C
Explanation
The date() function returns a formatted string representing a date. You can exercise an enormous amount of control over the format that date() returns with a string argument that you must pass to it.
Q 18 - Which of the following method connect a MySql database using PHP?
Answer : A
Explanation
PHP provides mysql_connect function to open a database connection.
Q 19 - Which of the following method can be used to create a MySql database using PHP?
Answer : B
Explanation
PHP uses mysql_query function to create a MySQL database.
Q 20 - Which of the following method can be used to close a MySql database using PHP?
Answer : C
Explanation
PHP uses mysql_close function to close a MySQL database.
Q 21 - Which of the following method can be used to parse an XML document using PHP?
Answer : C
Explanation
To create a SimpleXML object from an XML document stored in a string, pass the string to simplexml_load_string( ). It returns a SimpleXML object.
Answer : A
Explanation
Yes! class can be created in PHP.
Q 23 - Which of the following method acts as a constructor function in a PHP class?
Answer : B
Explanation
PHP provides a special function called __construct() to define a constructor. You can pass as many as arguments you like into the constructor function.
Q 24 - Which of the following method acts as a destructor function in a PHP class?
Answer : B
Explanation
Like a constructor function you can define a destructor function using function __destruct(). You can release all the resourceses with-in a destructor.
Q 25 - final keyword prevents child classes from overriding a method by prefixing the definition with final?
Answer : A
Explanation
PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | A |
2 | A |
3 | B |
4 | C |
5 | D |
6 | A |
7 | A |
8 | B |
9 | C |
10 | A |
11 | B |
12 | C |
13 | D |
14 | C |
15 | D |
16 | A |
17 | C |
18 | A |
19 | B |
20 | C |
21 | C |
22 | A |
23 | B |
24 | B |
25 | A |