Multiple Choice Questions On PHP Basis Part-1

Here are the collections of multiple choice objective questions on PHP language features, advantages and capabilities. It also includes MCQ on different ways of writing PHP code for web pages, printf( ) and echo( ) statements used in PHP, different data types supported by PHP, variable declaration and PHP's superglobal variables. 

1. State whether the following statements about about PHP are True or False.
i) A useful PHP script can consist of a little as one line; unlike c, there is no need for the mandatory inclusion of libraries.
ii) In PHP, you can effect numerous changes to a value on the same line by stacking functions in a particular order.
A) False, True
B) True, True
C) False, False
D) True, False

2. Which of the following are the advantages of PHP language.
i) There is no need to explicitly create, typecast or destroy a variable.
ii) It will automatically destroy variables and return resources to the system when the scripts completes.
iii) It allows the developer to concentrate almost exclusively on the final goal, namely a working application.
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii

3. The commonly used type specifier ......................... is considered an integer which can be presented as a character corresponding to that ASCII value.
A) %c
B) %b
C) %d
D) %o

4. Which of the following is/are the correct ways to display a text with PHP code.
i) <? php echo "This text is generated with PHP"; ?>
ii) <? print "This text is generated with PHP"; ?>
iii) <? ="This text is generated with PHP"; ?>
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii

5. State whether the following statements about print( ) and echo( ) statements are True or False.
i) print( ) is capable of outputting multiple strings.
ii) echo( ) function is faster because it returns noting, whereas print( ) will return 1 if the statement is successfully output.
A) False, True
B) True, False
C) False, False
D) True, True

6. Which of the following is/are the ways of commenting the code in PHP.
i) <? php //This is PHP comment ?>
ii) <? php #This is PHP comment ?>
iii) <? php /*This is PHP comment ?>
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii

7. The .......................... statement is ideal when you want to output a blend of static text and dynamic information stored within one or several variables.
A) echo( )
B) printf( )
C) print( )
D) sprintf( )

8. ..................... is a commonly used type specifier which can be considered an integer and presented as a signed decimal number.
A) %c
B) %b
C) %d
D) %o

9. PHP can do which of the following
i) Create and manipulate Adobe Flash and Portable Document Format(PDF) files.
ii) Tightly integrate with a wide array of credit card processing solutions.
iii) Evaluate a password for guess-ability by comparing it to language dictionaries and easily broken patterns.
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii

10. Which of the following is/are the valid examples of integers used in PHP.
i) 52           ii) -6590                 iii) 4.23               iv) oxc3
A) i, ii and iii only
B i, ii and iv only
C) ii, iii and iv only
D) All i, ii, iii and iv

11. Which of the following is/are the valid examples of floats used in PHP.
i) 4.0        ii) 3.7e4              iii) 2.12E+11           iv) 0755
A) i, ii and iii only
B i, ii and iv only
C) ii, iii and iv only
D) All i, ii, iii and iv

12. .................. is a type related function which returns the type of the provided variable.
A) gettype( )
B) settype( )
C) totype( )
D) returntype( )

13. ........................ is a type related function which converts a variable to the type specified by type.
A) gettype( )
B) settype( )
C) totype( )
D) returntype( )

14. State whether the following statements about PHP identifiers are True or False.
i) An identifier can consist of one or more characters must begin with a letter or an underscore.
ii) Identifiers can consist of only letters, numbers, underscore characters and ASCII characters.
A) False, True
B) True, False
C) False, False
D) True, True

15. ...................... eliminate the possibility of unexpected side effects that can result from globally accessible variables that are modified, intentionally or not.
A) Local variables
B) Function parameters
C) Global variables
D) Static variables

16. ........................... are declared after the function name and inside parentheses.
A) Local variables
B) Function parameters
C) Global variables
D) Static variables

17. The PHP superglobal variable ............................. contains information of the URL of the page that referred the user to the current location.
A) $_SERVER['REQUEST_URI']
B) $_SERVER['HTTP_REFERER']
C) $_SERVER['HTTP_USER_AGENT']
D) $_SERVER['REMOTE_ADDR']

18. The PHP superglobal variable ...................... contains the path component of the URL.
A) $_SERVER['REQUEST_URI']
B) $_SERVER['HTTP_REFERER']
C) $_SERVER['HTTP_USER_AGENT']
D) $_SERVER['REMOTE_ADDR']

19. ..................................is the client's user agent, which typically offfers information about both the operating system and browser.
A) $_SERVER['REQUEST_URI']
B) $_SERVER['HTTP_REFERER']
C) $_SERVER['HTTP_USER_AGENT']
D) $_SERVER['REMOTE_ADDR']

20. Which of the following is/are the superglobal variables used in PHP.
i) $_GET               ii) $_SET                  iii) $_POST                  iv) $_ENV
A) i, ii and iii only
B i, iii and iv only
C) ii, iii and iv only
D) All i, ii, iii and iv
 

Answers

1. B) True, True
2. D) All i, ii and iii
3. A) %c
4. D) All i, ii and iii
5. A) False, True
6. D) All i, ii and iii
7. B) printf( )
8. C) %d
9. D) All i, ii and iii
10. B i, ii and iv only
11. A) i, ii and iii only
12. A) gettype( )
13. B) settype( )
14. D) True, True
15. A) Local variables
16. B) Function parameters
17. B) $_SERVER['HTTP_REFERER']
18. A) $_SERVER['REQUEST_URI']
19. C) $_SERVER['HTTP_USER_AGENT']
20. B i, iii and iv only

Read Next:Multiple Choice Questions On PHP Basis Part-2

Multiple Choice Questions On PHP Basis Part-1
2017-09-23T21:51:00-07:00
Shuseel Baral
Internet & Web Designing|Multiple Choice Question (MCQ)|PHP|