1. Which of the following is/are the valid identifiers
i) !sum ii) Size iii) _variable iv) 4count
A) i and ii only
B) ii and iii only
C) iii and iv only
D) i, ii and iii only
2. State whether the following statements about identifiers are True or False.
i) Identifiers are case sensitive
ii) Identifiers can be any length
iii) An identifier name can be identical to any PHP’s predefined keywords.
A) i-True, ii-False, iii-True
B) i-True, ii-True, iii-True
C) i-False, ii-True, iii-False
D) i-True, ii-True, iii-False
3. The ……………………… is a superglobal variable that stores information passed into the script through HTTP cookies.
A) $COOKIE
B) $_COOKIE
C) $SET_COOKIE
D) $ADD_COOKIE
4. While uploading files using POST in PHP, an upload status code ………………… will be populated while the file size exceeds the maximum size imposed by the upload_max_file size directive.
A) UPLOAD_ERR_INI_SIZE
B) UPLOAD_ERR_FORM_SIZE
C) UPLOAD_ERR_OK
D) UPLOAD_ERR_PARTIAL
5. ……………… error will occur when the file size exceeds the maximum size imposed by an optional MAX_FILE_SIZE hidden form field parameter.
A) UPLOAD_ERR_INI_SIZE
B) UPLOAD_ERR_FORM_SIZE
C) UPLOAD_ERR_OK
D) UPLOAD_ERR_PARTIAL
6. The ………………………. superglobal is a catch-all of sorts, recording variables passed to a script via the GET, POST and COOKIE methods.
A) $GLOBALS
B) $_SESSION
C) $_ENV
D) $_REQUEST
7. The …………………….. superglobal array can be thought of as the superglobal superset and contains a comprehensive listing of all variables found in the global scope.
A) $GLOBALS
B) $_SESSION
C) $_ENV
D) $_REQUEST
8. The ………………… function in PHP defines a constant by assigning a value to a name.
A) define( )
B) const( )
C) constant( )
D) define_constant( )
9. The optional parameter …………………. is included and assigned TRUE, subsequent references to the constant will be case insensitive.
A) non_sensitive
B) no_case
C) case_insensitive
D) non_case_sensitive
10. ……………….. are particularly useful when working with values that definitely will not require modification.
A) Constants
B) Variables
C) Expressions
D) Keywords
11. Which of the following is/are the examples of expressions used in PHP.
i) $abc=10; ii) $sum=100+$first_sum; iii) $adder++;
A) i and ii only
B) ii and iii only
C) i and iii only
D) All i, ii and iii
12. The PHP operator index enclosure [ ] has ………………… associativity.
A) left
B) right
C) both
D) NA
13. The PHP operators Boolean AND and Boolean OR [ && || ] has ………………… associativity.
A) left
B) right
C) both
D) NA
14. State whether the following statements about for loops in PHP.
i) The first expression in for loop is evaluated by default at the first iteration of the loop.
ii) Any of the expressions can be empty, their purpose substituted by the logic embedded within the for the block.
A) True, False
B) False, True
C) False, False
D) True, True
15. …………………. in PHP offers a convenient means for outputting large amounts of text.
A) Heredoc
B) Newdoc
C) Largedoc
D) Olddoc
16. State whether the following statements about Heredoc syntax are True or False.
i) The opening identifier must be preceded with three left angle brackets (<<<)
ii) It can be preceded by spaces or any other extraneous character.
A) True, False
B) False, True
C) False, False
D) True, True
17. Consider the following code
<? php
$count=12;
do{
printf("%d squared=%d<br/>", $count, pow($count,2));
} while($count<11);
?>
What will be the output of the code.
A) 12 squared 141
B) 12 squared=141
C) “12 squared=141”
D) Execution error
18. The ………………………….. statement will evaluate and produces the same result as copying the data from the file specified into the location in which the statement appears.
A) require( )
B) define( )
C) include( )
D) evaluate( )
19. If …………………… is placed within an if statement, that evaluates to false, the file would be included anyway.
A) require( )
B) define( )
C) include( )
D) evaluate( )
20. State whether the following file inclusion statements are True or False.
i) If a file has already been included, include_once( ) will not execute.
ii) After require_once( ) is encountered, any subsequent attempts to include the same file will be ignored.
A) True, False
B) False, True
C) False, False
D) True, True
Answers
1. B) ii and iii only
2. D) i-True, ii-True, iii-False
3. B) $_COOKIE
4. A) UPLOAD_ERR_INI_SIZE
5. B) UPLOAD_ERR_FORM_SIZE
6. D) $_REQUEST
7. A) $GLOBALS
8. A) define( )
9. C) case_insensitive
10. A) Constants
11. D) All i, ii and iii
12. B) right
13. A) left
14. D) True, True
15. A) Heredoc
16. A) True, False
17. B) 12 squared=141
18. C) include( )
19. A) require( )
20. D) True, True
Read Next: 20 Best MCQ Questions on PHP Functions