WEB PHP MCQ
WEB PHP MCQ
1. The _______________ syntax of the language specifies such things as what variable names
look like, what characters are used for comments, and how program statements are
separated from each other.
A. Highest-level
B. Lowest-level
C. Slow-level
D. Fast-level
9. _____________ is a cross-platform application that can run on Windows, Linux, and macOS.
A. HAMP
B. Hadoop
C. XAMPP
D. WampServer
UNIT-02
Here are the questions with their options:
1. _____________ statements are the set of commands used to perform different actions
based on different conditions.
A. Assignment
B. Operational
C. Conditional
D. Indictive
6. ___________ statement loops through a block of code for each element in an array.
A. For
B. For each
C. Each
D. Each block
7. The loop that executes a block of code repeatedly until the condition is false. Once the
condition gets false, it exits from the body of the loop.
A. While
B. Switch
C. Case
D. If
8. ____________ loop is called as an entry control loop because the condition is checked
before entering the loop body.
A. Do-while
B. If
C. For each
D. While
9. Which of the following loops uses a semicolon to terminate the loop?
A. while
B. do-while loop
C. for
D. for each
10. Supposing that the developer has to develop a program and knows in advance how many
times the script should run. The developer will be using
A. Switch
B. For each
C. For loop
D. None of the above
11. In the XML style, you normally embed PHP in a document through what is commonly called a
PHP statement, but is actually an ____________.
A. XML header
B. XML footer
C. XML docs
D. XML directive
12. Line breaks are allowed within the XML processing directive.
A. True
B. False
13. ______________ tag has been invented to allow client-side scripting within HTML pages.
A. .aspx
B. .php
C. Script
D. Embed
15. An XML processing directive is a command embedded in an XML document for some
application to process.
A. True
B. False
UNIT – 03
1. PHP array is an ___________ map and contains value on the basis of key.
A. Isolated
B. Ordered
C. Unordered
D. Emergent
2. A class is a template for objects, and an object is an instance of a class.
A. True
B. False
3. Which of the following function gets the name of the class of the given object?
A. get_class()
B. name_class()
C. classname_get()
D. none of the above
4. ____________ function checks if all of the characters in the provided string, text, are
lowercase letters.
A. type_lower()
B. lower()
C. str_lower()
D. ctype_lower()
6. Ceil() function rounds fractions down and floor() function rounds fractions up.
A. True
B. False
7. The _________ function changes the permissions of the specified file and returns true on
success and false on failure.
A. chdir()
B. chmod()
C. permit()
D. chperm()
9. Which of the following function is used to get the ASCII value of a character in PHP?
A. val()
B. asc()
C. ascii()
D. chr()
11. __________ error occurs when the PHP compiler understands the PHP code but it recognizes
an undeclared function. This means that function is called without the definition of function.
A. Parse
B. Semantic
C. Fatal
D. Syntax
12. Which of the following is/are error(s) that can be handled by PHP error handling functions?
A. Parse errors
B. Fatal error
C. Syntax Error
D. All of the above
13. Which of the following statement is/are true for the date and time functions in PHP?
A. Allow you to get the date and time from the server where your PHP scripts are running.
B. Allow you to format the date and time in many different ways.
C. Allow you to modify the date.
D. All of the above
15. In PHP call by reference, in order to pass value as a reference, you need to use
_____________ symbol before the argument name.
A. hash (#)
B. ampersand (&)
C. sigil ($)
D. power (^)
UNIT – 04
Here are the answers for the self-assessment questions with options:
5. PHP maintains an array where it stores all the global variables that we defined in an
application. Such an array is called __________ array.
A. Static
B. Global
C. Random
D. Fixed
6. $_SERVER is a PHP super global variable which holds information about _______.
A. Headers
B. Paths
C. Script locations
D. All of the above
8. __________ function accepts variable reference and base parameters to return an integer by
converting variable type with respect to the base.
A. Intern ()
B. Internal ()
C. Include ()
D. Interval ()
9. ___________ function will print the array of data with more information to the browser such
as its length, type information.
A. var_dump()
B. dump()
C. echo()
D. printer()
10. ___________ function in PHP converts the value of a variable into a storable data format,
whereas, ________ is used to convert the storable data format back to its original form.
A. store (), unstore()
B. serialize(), unserialize()
C. convert (), unconvert()
D. varst(), dvarst()
11. Anonymous function is a function without any user-defined name. Such a function is also
called ___________ function.
A. Lambda
B. Variable
C. Anon
D. Close
12. The date_format() function returns ___________ which represents the date formatted
according to the specified format on successful formatting; otherwise, it returns false on
failure.
A. String
B. Character
C. ASCII
D. Float
14. The checkdate() function accepts _____________ as parameters and verifies whether it is a
Gregorian date or not.
A. Month of a date
B. Day of a date
C. Year of a date
D. All of the above
15. Which of the following statement is true for the date_timezone_set() function?
A. It accepts a DateTime object as a parameter.
B. It accepts a timezone object as parameter.
C. It sets the specified timezone to the given DateTime
D. All of the above
UNIT – 05
Here are the answers with options for the self-assessment questions:
4. Which of the following function is used to get the ASCII value of a character in PHP?
A. val()
B. asc()
C. ascii()
D. chr()
5. _____________ function removes whitespace and other predefined characters from the left
side of a string.
A. strim()
B. lefttrim()
C. ltrim()
D. lftrim()
6. The statement that aptly indicates the feature(s) for substr_count() function:
A. It counts the number of times a substring occurs in the given string.
B. It is a built-in function.
C. It is a case-sensitive function.
D. All of the above
7. Which of the following is the correct way to print "Hello World" in PHP?
A. "Hello World";
B. write ("Hello World");
C. echo "Hello World";
D. None of the above
8. The _____________ function is used to get the reverse version of any string.
A. strrev()
B. strrevs()
C. rev()
D. revstrr()
9. Which of the following statement(s) is true regarding the abs() function in PHP?
A. It is an inbuilt function in PHP which is used to return the absolute (positive) value of a
number.
B. It is identical to what we call modulus in mathematics.
C. Accepts single parameter value which holds the number whose absolute value you want
to find.
D. All of the above
12. ______________ function rounds the fractions up while __________ function rounds the
fractions down.
A. floor(), ceil()
B. ceil(), floor()
C. RoundUp(), RoundDown()
D. FracUp(), FracDown()
13. PHP offers 1000’s of built-in functions. The functions that offer a mechanism for the
developer to do some sort of mathematical calculations or similar stuff are:
A. Math functions
B. Formula functions
C. Calculate functions
D. Compute functions
15. Which of the following statement is/are true for pow() function in PHP?
A. It was introduced in PHP 4+ version.
B. It accepts two arguments say x and y. It calculates x raised to the power of y.
C. The return type is integer or float which depends upon the nature of the argument.
D. All of the above
UNIT – 06
Here are the answers with options for the self-assessment questions:
5. The array with a string index where instead of linear storage, each value can be assigned a
specific key is
A. Indexed array
B. Multi-dimensional array
C. Associative array
D. None of the above
8. The indexed arrays used to store any type of elements have default index starting at
_________.
A. One
B. Zero
C. Two
D. Infinite
9. In array traversal, the ____________ function is invoked to restore the array pointer to the
first element in the array.
A. Reach
B. First
C. Reset
D. Support
10. The indexed arrays can be used to store any type of elements, but an index is always
a_________.
A. String
B. Date
C. Alphanumeric
D. Number
12. Which function displays structured information about variables including its type and value?
A. Asort()
B. Ksort()
C. Sort()
D. Var_dump()
14. ____________ function takes an array as input and splits that array into smaller chunks of
the given size.
A. array_break()
B. array_chunk()
C. array_crop()
D. array_cut()
15. Sorting of ___________ arrays includes arranging elements according to the keys or values.
A. Associative
B. Numeric
C. Indexed
D. Definite
UNIT - 07
Here are the answers with options for the self-assessment questions:
2. A(n) ______________ database is one that can be dispersed or replicated among different
points in a network.
A. optical
B. analytical
C. distributed
D. back-end
3. MySQL database is of type
A. Access Jet Database Engine
B. Object-relational DBMS
C. General Public
D. Single platform database
5. The database classification can be done on the basis of type of their content(s) like,
A. bibliographic
B. document-text
C. statistical
D. all of the above
6. The rows in the database table are called as ____________ that contain all the database
information.
A. Attributes
B. records
C. lines
D. links
7. ____________ database is one that is congruent with the data defined in object classes and
subclasses.
A. Convergent
B. Object-oriented programming
C. Class
D. Insecure
9. MySQL is the most popular database system used with PHP. Which of the following
statement(s) is/are true for MySQL?
A. MySQL is a database system that runs on a server
B. MySQL uses standard SQL
C. MySQL compiles on a number of platforms
D. All of the above
10. The MySQL extension’s function names, parameters, error handling, and so on are
completely different from those of the other database extensions.
A. True
B. False
11. In MySQLi extension, the ‘i’ is abbreviation that stands for
A. impact
B. included
C. injected
D. improved
12. PDO is a PHP extension used for connecting to MySQL databases. Here, PDO stands for
A. PHP Data Obstacles
B. PHP Database Orientation
C. PHP Database Objects
D. PHP Data Objects
13. HTML form is a document which stores information of a user on a web server using
interactive controls.
A. True
B. False
15. PHP ___________ method is a PHP super global variable which is used to collect data after
submitting the HTML form.
A. $_POSTING
B. $_POST
C. $_POSTAGE
D. $_SUPER
UNIT – 08
2. ____________ graphics use geometrical primitives such as points, lines, curves, or polygons
to represent images.
A. Raster
B. Vector
C. Line
D. Coordinate
5. Which of the following is/are major consideration(s) to choose the necessary file type?
A. Compression quality
B. Transparency
C. Documents
D. All of the above
6. A standard web page containing text and graphics is created through a series of HTTP
requests from the web browser, each answered by a response from the web server.
A. True
B. False
10. Imagecolorallocate() function is another inbuilt PHP function mainly used to implement a
new color to an image. It returns the color of an image in an RGB format which stands for
A. Red, Green, Black
B. Red, Green, Brown
C. Red, Green, Blue
D. Red, Green, Blended
11. In the imagepolygon() function syntax as “imagepolygon(Gd Image $image, array $points, int
$num_points, int $colour)”, the parameter that defines the total number of points or vertices
in the polygon is
A. array $points
B. $num_points
C. $image
D. $colour
12. In order to add the text in a TrueType font to an image, the function that can be used is:
A. Imagefontheight()
B. Imagettf()
C. Imagetext()
D. Imagettftext()
13. The function imagefontheight() retrieves the font height and returns the ___________ height
of a character in the specified font.
A. Pixels
B. Format
C. Vertice
D. Upper
14. _____________ Function helps to scale an image using the given new width and height.
A. Imagescalar()
B. Scaleimage()
C. Imagescale()
D. imgscl()
15. Which of the following function(s) can be used to resize the image in PHP?
A. ImageCopyResized()
B. ImageCopyResampled()
C. Imagescale()
D. All of the above
UNIT -09
5. ______________ is a set of PHP code you include in your scripts with the require function, so
it doesn’t require any server-side configuration or support, meaning you can use it even
without support from your host.
A. FPDF library
B. XPDF library
C. Workgroup library
D. Session library
6. The addpage(orientation, paper size, rotation) is used for adding a page in a PDF using PHP.
The orientation attribute here can take ______________ layouts.
A. portrait
B. landscape
C. both
D. none of the above
9. In the function, Settextcolor(int r , int g, int b), the minimum and maximum value taken by ‘r’,
‘g’ or ‘b’ can be
A. 0 and 255
B. 1 and 255
C. 0 and 125
D. 1 and 125
10. Which of the following is/are way(s) to alter the appearance of the text?
A. Bold
B. Underline
C. Italics
D. All of the above
11. ____________ function creates an internal link and returns its identifier.
A. setlink()
B. addLink()
C. internlink()
D. linker()
12. _______________ method is used to track the overall page count in the PDF document
before it is sent to the browser.
A. AliasNbPages()
B. trackPages()
C. PageCounter()
D. trackCount()
13. PHP helps to add images and graphics to the PDF pages using the inbuilt function such as
_______________.
A. imageSetting()
B. setImage()
C. imagePixel()
D. image()
15. The syntax, image(file, x, y, w, h, type, link) is used to insert an image in a PDF. The type
attribute can take _________ files.
A. JPG
B. GIF
C. PNG
D. All of the above
UNIT -10
2. ______________ is a markup language and file format for storing, transmitting, and
reconstructing arbitrary data.
A. Orbit
B. XML
C. R programming
D. HTTP
7. XML was designed to be a software and hardware independent tool used to transport and
store data, with focus on what data is.
A. True
B. False
10. XML provides easy communication of the hierarchy of data elements using the ________
structure.
A. linked list
B. queue
C. tree
D. graph
13. ______________ is a language for transforming XML documents into different XML, HTML,
or any other format.
A. XSMT
B. XMTL
C. XSLT
D. XMIT
14. _____________ function is used for converting an XML string into an object, then output the
keys and elements of the object.
A. simplexml_convert_string()
B. simplexml_loadstring()
C. simplexml_output_string()
D. simplexml_set_string()
15. An XML parser is a program that translates the XML document into an XML DOM object.
A. True
B. False
UNIT – 11
2. ____________ generates a fatal error, i.e., E_COMPILE_ERROR, and stops the execution of
the script.
A. Include
B. Require
C. feof
D. fputs
3. The use of ________ does not stop the execution of the script even if any error occurs.
A. include
B. require
C. feof
D. fputs
10. The _________ function is an inbuilt function in PHP which is used to remove the content
from the file by emptying it.
A. set()
B. link()
C. unset()
D. unlink()
11. ____________ function is used to write content of the string into file.
A. fwriter()
B. fwrite()
C. fcontent()
D. fstring()
12. When a file is opened in write mode, all the existing data in the file is erased and new data
can be written to the file using the fwrite() function.
A. True
B. False
13. The unset() command takes the ____________ as input and removes that element from the
array.
A. array key
B. array pointer
C. array element
D. array bound
14. Which of the following statement is/are TRUE for fputs() function?
A. It is an alias of the fwrite() function.
B. An inbuilt function which is used to write to an open file.
C. Returns the number of bytes written on success.
D. All the above.
UNIT -12
1. ___________ is a PHP super global that can be used to collect the form data.
A. $_GETCH
B. $_POST
C. $_GETTING
D. $_GETFL
3. Which of the following statement reflects, POST is better method than GET?
A. GET is more secure compared to POST.
B. Data is sent as a part of the URL in GET.
C. POST can be used for sending passwords or other sensitive information.
D. None of the above.
5. A _____________ is a document containing blank fields, that the user can fill the data or
user can select the data.
A. Form
B. Format
C. Formal
D. Session
10. _____________ is a super global variable that returns the filename of the currently
executing script.
A. $_SERVER["PHP_SELFLESS"]
B. $_SERVER["PHP_SELF"]
C. $_SERVERFUL["PHP_SELF"]
D. $_SERVERLESS["PHP_SELF"]
12. For form validation, you need to check whether the form has been submitted using
$_SERVER["REQUEST_METHOD"].
A. True
B. False
13. Which of the following statement is/are TRUE for PHP form validation?
A. It is the backend validation method.
B. It is also called as server-side validation.
C. It prevents entering invalid data into the input field.
D. All the above.
14. Which of the following correspond to the rules for creating form validation?
A. All the Input Fields must be required.
B. Email Address must be a valid format containing the "@" symbol.
C. The password must contain a combination of one uppercase & lowercase letter, a number,
special characters, and a minimum length of 8 characters. It will not accept any white spaces.
D. All the above.
15. Using the forms, the data can be collected from the user and can be sent directly to the
server through PHP scripting. The <form> element has two important attributes: action and
method.
A. True
B. False
UNIT -13
3. A ___________ is a way to store information (in variables) to be used across multiple pages.
A. Scope
B. Setter
C. Session
D. Spare
5. _________________ is a PHP global variable that is used for setting the session variable.
A. $_SETSESSION
B. $_SESSION
C. $_SESSION_GLOBAL
D. $_SESSIONSETUP
6. The session_start() function creates a session or resumes the current one based on a session
identifier passed via a ________ request, or passed via a cookie.
A. GET
B. GETCHS
C. GETCH
D. GETTS
9. The function used to destroy all the data associated with the current session is _________.
A. session_unset()
B. session_current()
C. session_destroy()
D. currentsession_destroy()
10. The cookie is created at the server side and saved to the client browser. Each time when the
client sends a request to the server, the cookie is embedded with the request.
A. True
B. False
11. A cookie in PHP is a small file with a maximum size of 4KB that the __________ stores on the
client computer.
A. Web browser
B. Web server
C. Network
D. Cacher
14. You cannot delete a cookie by calling setcookie() function with the cookie name and any
value.
A. True
B. False
15. ___________ parameter is used to set the expiry timestamp of the cookie after which the
cookie can’t be accessed.
A. Timer
B. Session
C. Timestamping
D. Expiry
UNIT -14
Here are the questions with their options:
2. ______________ database is one that is congruent with the data defined in object classes
and subclasses.
A. Convergent
B. Object-oriented programming
C. Class
D. Insecure
3. MySQL is the most popular database system used with PHP. Which of the following
statement(s) is/are true for MySQL?
A. MySQL is a database system that runs on a server
B. MySQL uses standard SQL
C. MySQL compiles on several platforms
D. All the above
4. The MySQL extension’s function names, parameters, error handling, and so on are
completely different from those of the other database extensions.
A. True
B. False
7. PHP provides an additional set of predefined arrays containing variables from the web server,
the environment, and user input. The new arrays are called as_____________.
A. Varglobal
B. Subglobals
C. Superglobals
D. Preset globals
8. ________ is an associative array of items uploaded to the current script via the HTTP POST
method.
A. $_DELETE
B. $_SETTING
C. $_FILES
D. $_GET
11. ___________ is a programmer-defined data type, which includes local functions as well as
local data.
A. Class
B. Pointer
C. Degree
D. Inheritance
13. Which of the following statement aptly indicates the member variables?
A. Member variables are defined inside a class.
B. The data will be invisible to the outside of the class and can be accessed via member
functions.
C. Member variables are also called attributes of the object once an object is created.
D. All the above.
14. Polymorphism is an object-oriented concept where the same function can be used for
different purposes.
A. True
B. False
15. Any representation of data in which the implementation details are hidden represents
_____________.
A. Data extraction
B. Data exclusion
C. Data abstraction
D. Data surfacing