PHP Multiple-Choice Questions for online exam

PHP Multiple-Choice Questions for online exam

Solve PHP Multiple-Choice Questions to prepare better for GATE. If you wish to learn more about PHP language and PHP MCQs, you can check notes, mock tests, and previous years’ question papers. Gauge the pattern of MCQs on PHP by solving the ones that we have compiled below for your practice:

PHP Multiple-Choice Questions

1. In PHP, the variable name starts with:

a. # (Hash)

b. & (Ampersand)

c. $ (Dollar)

d. ! (Exclamation)

Answer: (c) $ (Dollar)

2. In PHP, out of the following, which one is NOT a variable scope?

a. Global

b. Static

c. Local

d. Extern

Answer: (d) Extern

3. Which of these is the correct way in which we can add a comment in PHP?

a. // ……

b. /* …… */

c. & …… &

d. Both (a) and (b)

Answer: (d) Both (a) and (b)

4. In PHP, which of these is the use of the strlen() function?

a. It returns the string’s type

b. It returns the string’s length

c. It returns the string’s value

d. It returns string’s both type and value

Answer: (b) It returns the string’s length

5. In PHP, which of these starts with a double underscore (__)?

a. Default constants

b. Magic constants

c. User-defined constants

d. Inbuilt constants

Answer: (b) Magic constants

6. In PHP, which of these is used for concatenation?

a. * (Asterisk)

b. + (plus)

c. append()

d. . (dot)

Answer: (d) . (dot)

7. In PHP, which of these is the correct way in which we can create a function?

a. New_function myFunction()

b. Function myFunction()

c. Create myFunction()

d. None of the above

Answer: (b) Function myFunction()

8. In PHP, which of these is the correct way in which we can define a variable?

a. $variable name as value;

b. $variable_name = value

c. $variable_name = value;

d. $variable name = value;

Answer: (c) $variable_name = value;

9. In PHP, which of these functions is used to find various files?

a. fold()

b. file()

c. glob()

d. None of the above

Answer: (c) glob()

10. In PHP, which of these functions is used to get any ASCII value of the given character?

a. chr()

b. ascii()

c. asc()

d. val()

Answer: (a) chr()

11. Which of these functions is used for sorting an array in a descending order?

a. rsort()

b. dsort()

c. asrot()

d. sort()

Answer: (a) rsort

12. In PHP, which of these do we use to end a statement?

a. ; (semicolon)

b. . (dot)

c. / (slash)

d. ! (exclamation)

Answer: (a) ; (semicolon)

13. In PHP, what is the correct way in which we can print “Hello World”?

a. write(“Hello World”);

b. echo “Hello World”;

c. “Hello World”;

d. None of the above

Answer: (b) echo “Hello World”;

14. Out of the following functions in PHP, which of these is used to compress a string?

a. zip_compress()

b. compress()

c. zip()

d. gzcompress()

Answer: (d) gzcompress()

15. Out of the following functions, which one converts a string to all uppercases?

a. strtoupper()

b. struppercase()

c. uppercase()

d. upper()

Answer: (a) strtoupper()

16. In PHP, _____________ is a function that can be used for concatenating array elements for the formation of a single delimited string:

a. concat()

b. implode()

c. concatenate()

d. explode()

Answer: (b) implode()

17. The output of this program would be:

<?php

echo ucwords(“visit us at thinkLearn.com”);

?>

a. Visit us at thinkLearn.com

b. visit us at thinkLearn.com

c. Visit Us At ThinkLearn.com

d. Visit us at ThinkLearn.com

Answer (c) Visit Us At ThinkLearn.com

18. The output of the program mentioned below would be:

<?php

$a = array(16, 5, 2);

echo array_product($a);

?>

a. 32

b. 80

c. 1652

d. 160

Answer: (d) 160

19. Which of these PHP functions would perform the conversion of an English text datetime into the Unix timestamp?

a. strtotime()

b. str_to_time()

c. strtodate()

d. None of the above

Answer: (a) strtotime()

20. In PHP, which of the following functions would return the time of the sunrise on a particular day and at a particular location?

a. sunrise()

b. date_sunrise()

c. date-sunrise()

d. None of the above

Answer: (b) date_sunrise()

Also read

Dheeraj Pal:

This website uses cookies.