Explore topic-wise MCQs in Php.

This section includes 86 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

We can use ___ to comment a single line?i) /?ii) //iii) #iv) /* */

A. Only ii)
B. i), iii) and iv)
C. ii), iii) and iv)
D. Both ii) and iv)
Answer» D. Both ii) and iv)
2.

Which of following variables can be assigned a value to it?i) $3helloii) $_helloiii) $thisiv) $This

A. All of the mentioned
B. Only ii)
C. ii), iii) and iv)
D. ii) and iv)
Answer» E.
3.

Which of the following php statement/statements will store 111 in variable num?i) int $num = 111;ii) int mum = 111;iii) $num = 111;iv) 111 = $num;

A. Both i) and ii)
B. All of the mentioned
C. Only iii)
D. Only i)
Answer» D. Only i)
4.

Windows, Apache, MySQL, Perl, PHP, Python all of these are categories in

A. LAMP stack
B. WAMP stack
C. CAMP stack
D. None of them
Answer» C. CAMP stack
5.

Which one from followings is not included in user's mailing list?

A. php.pear
B. php.bugs
C. php.il8n
D. php.functions
Answer» E.
6.

Server side scripting websites consists of two main parts, one is scripting language and other is

A. Scripting engine
B. User interaction mode
C. Server interaction mode
D. None of them
Answer» B. User interaction mode
7.

PHP is a scripting language, whereas java is a

A. Compiled language
B. Markup language
C. Tags language
D. None of them
Answer» B. Markup language
8.

Which PHP error causes a termination of script?

A. Notice error
B. Fatal error
C. Warning error
D. None of them
Answer» C. Warning error
9.

Errors that are automatically be suppressed by system, is called as

A. Notice error
B. Fatal error
C. Warning error
D. None of them
Answer» B. Fatal error
10.

Everything compatible with PHP on client side is also compatible with

A. Apache
B. MySQL
C. Perl
D. HTML
Answer» E.
11.

For getting information of any type of error which function is used by PHP

A. get_error ( )
B. error ( )
C. getMessage ( )
D. message ( )
Answer» D. message ( )
12.

Linux, Apache, MySQL, Perl, PHP, Python all of these are categories in

A. LAMP stack
B. WAMP stack
C. CAMP stack
D. None of them
Answer» B. WAMP stack
13.

What is the value of $a and $b after the function call?

A. a is 3 and b is 4
B. a is 4 and b is 3
C. Both are 3
D. Both are 4
Answer» C. Both are 3
14.

Which of the following PHP statements will output Hello World on the screen?i) echo (“Hello World”);ii) print (“Hello World”);iii) printf (“Hello World”);iv) sprintf (“Hello World”);

A. i) and ii)
B. i), ii) and iii)
C. All of the mentioned
D. i), ii) and iv)
Answer» C. All of the mentioned
15.

Which of the following must be installed on your computer so as to run PHP script?i) Adobe Dreamweaverii) PHPiii) Apacheiv) IIS

A. All of the mentioned.
B. Only ii)
C. ii) and iii)
D. ii), iii) and iv)
Answer» E.
16.

Printf ( ) function sends resulting string

A. Directly to the output
B. To the sprintf ( ) function
C. To the scanf ( ) function
D. None of them
Answer» B. To the sprintf ( ) function
17.

Which of the looping statements is/are supported by PHP?i) for loopii) while loopiii) do-while loopiv) foreach loop

A. i) and ii)
B. i), ii) and iii)
C. All of the mentioned
D. None of the mentioned
Answer» D. None of the mentioned
18.

Which apache log file notes every HTTP request, including its date, time, and result?

A. Apache/logs/access.log
B. Apache/logs/error.log
C. Apache/request_file.log
D. Apache/HTTP/request.log
Answer» B. Apache/logs/error.log
19.

Response code 200 series indicates

A. Client side error
B. Redirection
C. Success
D. Server side error
Answer» D. Server side error
20.

An error that causes by failed code, is called as

A. Notice error
B. Fatal error
C. Warning error
D. None of them
Answer» D. None of them
21.

How many types of bugs plague during execution of program?

A. 1
B. 2
C. 3
D. 4
Answer» D. 4
22.

Include ( ) and include_once ( ) will generate a warning message on failure, While require ( ) and require_once ( ) will cause

A. A fatal error
B. Termination of script
C. No error
D. Both a and b
Answer» E.
23.

SAPI stands for

A. Java Service Access Point Identifier
B. Java Scripts Access Point Identity
C. Java Sockets Applet Point
D. None
Answer» B. Java Scripts Access Point Identity
24.

How many log files are maintained by Apache HTTP server?

A. One log file
B. Two log files
C. Three log files
D. None of them
Answer» C. Three log files
25.

Exceptions are caught and handled by using

A. Try control construct
B. Catch control construct
C. Exception control construct
D. Both a and b
Answer» E.
26.

A function that writes directly into log of operating system, is

A. dump ( )
B. syslog ( )
C. log ( )
D. var ( )
Answer» C. log ( )
27.

Error reporting is turned off and on in

A. IIS file
B. php.ini file
C. display_error file
D. error file
Answer» C. display_error file
28.

There are how many types of native errors in PHP?

A. 1
B. 2
C. 3
D. 4
Answer» D. 4
29.

For exception handling PHP5 introduced a class, name

A. Exe { }
B. Exception { }
C. Catch { }
D. None of them
Answer» C. Catch { }
30.

JSP stands for

A. Java Scripting Pages
B. Java Server Pages
C. Java Socket Pages
D. None of them
Answer» C. Java Socket Pages
31.

Which function is offered by PHP for connecting to a postgreSQL?

A. con ( )
B. con_psql ( )
C. pg_connect ( )
D. pg_con ( )
Answer» D. pg_con ( )
32.

There is some similarities between PHP and Java, that is

A. Syntax
B. Operators
C. Object Models
D. All of them
Answer» E.
33.

Most universally effective PHP tags style is

A. <php>
B. {? php?}
C. <? php?>
D. None of them
Answer» D. None of them
34.

We can integrate PHP into a java servlet environment using

A. IIS
B. SAPI
C. API
D. None of them
Answer» C. API
35.

While adding PHP to your HTML by putting it in a separate file which statement is correct?

A. include ('/filepath/filename')
B. require ('/filepath/filename')
C. include_once ('/filepath/filename')
D. All of them
Answer» E.
36.

For first time PHP5 included the

A. Exception handling object
B. Syntax handling object
C. Design handling functions
D. None of them
Answer» B. Syntax handling object
37.

Weblog favorites.php file includes a

A. links.php file
B. aboutme.php
C. semi static pages
D. All of them
Answer» E.
38.

Which of the following is/are a PHP code editor?i) Notepadii) Notepad++iii) Adobe Dreamweaveriv) PDT

A. Only iv)
B. All of the mentioned.
C. i), ii) and iii)
D. Only iii)
Answer» C. i), ii) and iii)
39.

If we want to use XML functions we must set off

A. short_open_tag <? ?>
B. slash_tag /
C. upload_tmp_dir
D. None of them
Answer» B. slash_tag /
40.

Which one from followings is used for configuring PHP?

A. Build time flags
B. php.ini file
C. Apache configuration files
D. All of them
Answer» E.
41.

In PHP default behavior for user defined functions is

A. Call-by-value
B. Call-by-reference
C. Call-by-type
D. None of them
Answer» B. Call-by-reference
42.

What does PHP stand for?i) Personal Home Pageii) Hypertext Preprocessoriii) Pretext Hypertext Processoriv) Preprocessor Home Page

A. Both i) and iii)
B. Both ii) and iv)
C. Only ii)
D. Both i) and ii)
Answer» E.
43.

To define a function with default arguments, simply you need to turn formal parameter names into

A. An assignment expression
B. An boolean expression
C. A function
D. None of them
Answer» B. An boolean expression
44.

In compile time installation PHP offers some

A. Functions
B. Flags
C. Classes
D. None of them
Answer» C. Classes
45.

Which is most important thing in configuration of PHP?

A. The php.ini file
B. Compile time options
C. Web server configuration
D. All of them
Answer» E.
46.

PHP stands for

A. PreHyper Processor
B. Hypertext Preprocessor
C. High Processor
D. Personal home page
Answer» C. High Processor
47.

Output of phpinfo ( ) function can be a potential bonanza for

A. Crackers
B. Hackers
C. Script-kiddies
D. All of them
Answer» E.
48.

Which of the conditional statements is/are supported by PHP?i) if statementsii) if-else statementsiii) if-elseif statementsiv) switch statements

A. Only i)
B. i), ii) and iv)
C. ii), iii) and iv)
D. All of the mentioned.
Answer» E.
49.

How many variables are necessary to set in php.ini file for sending an e-mail?

A. 1
B. 2
C. 3
D. No need to set any variable
Answer» C. 3
50.

Connecting websites to backend servers, processing data and controlling behavior of higher layers, all these things are done by

A. HTML language
B. CSS scripts
C. Java Scripts
D. Server side PHP scripts
Answer» E.