Server Side Scripting PHP Class 12 MCQs

Share Now

Server Side Scripting – PHP is an important chapter of Information Technology (IT) Class 12 as per the MSBSHSE (HSC Maharashtra Board) syllabus. This page provides chapter-wise MCQs based on the official textbook, covering PHP basics, syntax, variables, operators, control structures, forms, and database connectivity. These MCQs help students strengthen concepts, practice objective-type questions, and prepare confidently for board and online examinations.

Server Side Scripting PHP Class 12 MCQs

1. PHP stands for __.
a. Hypertext Preprocessor
b. Pre Hypertext Preprocessor
c. Hypertext Pro Processor
d. None of the above

Show Answer ⟶
a. Hypertext Preprocessor

2. PHP is especially suited for __.
a. Suitable for web development
b. It is a general-purpose scripting language.
c. PHP is widely used, and it is open source.
d. All of the above

Show Answer ⟶
d. All of the above

3. PHP can run on which of the following platforms?
a. Linux and Unix
b. Windows OS
c. Mac OS X
d. All of the above

Show Answer ⟶
d. All of the above

4. PHP is compatible with which of the following servers?
a. XAMPP
b. Apache
c. NGINX
d. All of the above

Show Answer ⟶
d. All of the above

5. What is the main role of a server in server-side scripting?
a. To run scripts directly on the client machine
b. To store cookies on the client browser
c. To only display static HTML pages
d. To act as a central repository of data and programmes shared by clients

Show Answer ⟶
d. To act as a central repository of data and programs shared by clients

6. What is the environment called that runs a server-side scripting language?
a. Web browser
b. Web server
c. Database server
d. Application server

Show Answer ⟶
b. Web server

7. Which of the following is NOT listed as a server-side programming language in the notes?
a. PHP
b. Java and JSP
c. Python
d. Client-based JavaScript

Show Answer ⟶
d. Client-based JavaScript

8. What are the three components required to run PHP scripts?
a. PHP parser, web server and web browser
b. PHP parser, Java compiler and JSP engine
c. PHP parser, database and client machine
d. None of the above

Show Answer ⟶
a. PHP parser, web server and web browser

9. What does PHP do with its code when generating output?
a. Displays the code directly to the user
b. Hides the code from the user and only shows output
c. Compiles the code into Java bytecode
d. None of the above

Show Answer ⟶
b. Hides the code from the user and only shows output

10. What are the features of PHP?
a. It is very simple and easy to use.
b. It is an interpreted language.
c. It is faster than other scripting languages.
d. All of the above

Show Answer ⟶
d. All of the above

11. What do you mean by open-source software?
a. You need not pay for the software.
b. You have to pay before use.
c. You have to pay lifetime
d. None of the above

Show Answer ⟶
a. You need not pay for the software.

12. Which of the following is true about PHP?
a. It is platform independent.
b. It is case sensitive.
c. It is open-source software.
d. All of the above

Show Answer ⟶
d. All of the above

13. PHP is a case-sensitive scripting language, but which of the following is not case-sensitive?
a. Functions
b. User-defined Functions
c. All keywords like ‘if’, ‘else’, ‘while’, ‘echo’, etc.
d. All of the above

Show Answer ⟶
d. All of the above

14. PHP supports variables without declaring their data type.
a. True
b. False

Show Answer ⟶
a. True

15. In PHP the data types are not set in a strict sense; we can do things like adding a string to an integer without causing an error.
a. True
b. False

Show Answer ⟶
a. True

16. Which of the following PHP codes is usually enclosed in special start and end processing instructions?
a. <?php and ?>
b. <-php and ->
c. <?php> and <?php>
d. None of the above

Show Answer ⟶
a.

17. All the PHP files have an extension of __.
a. .php
b. p.
c. .ph
d. .php

Show Answer ⟶
a. .php

18. A PHP script can be placed anywhere in the HTML document.
a. True
b. False

Show Answer ⟶
a. True

19. The ‘echo’ is used to display text on the web page.
a. True
b. False

Show Answer ⟶
a. True

20. __ is used to build robust web applications with MVC support. It simplifies tasks such as caching, security, authentication and many more.
a. Laravel
b. Symfony
c. Both a) and b)
d. None of the above

Show Answer ⟶
a. Laravel

21. _ is used for fast app development due to reusable components. It provides many app building blocks, like form management, etc.
a. Laravel
b. Symfony
c. Both a) and b)
d. None of the above

Show Answer ⟶
b. Symfony

22. In PHP, the variable names are case-sensitive.
a. True
b. False

Show Answer ⟶
a. True

23. What are the rules for declaring PHP variables?
a. A variable starts with the $ sign, followed by the name of the variable.
b. A variable name must start with a letter or the underscore character.
c. A variable name cannot start with a number.
d. All of the above

Show Answer ⟶
d. All of the above

24. A variable name can only contain alphanumeric characters and underscores (A-z, 0-9, and _).
a. True
b. False

Show Answer ⟶
a. True

25. Variable names are case-sensitive ($age and $AGE are two different variables).
a. True
b. False

Show Answer ⟶
a. True

26. Which of the following is considered a variable scope in PHP?
a. local
b. global
c. static
d. All of the above

Show Answer ⟶
d. All of the above

27. A variable declared outside a function is known as _.
a. local variable
b. global variable
c. static variable
d. All of the above

Show Answer ⟶
b. global variable

28. A variable declared within a function is known as _.
a. local variable
b. global variable
c. static variable
d. All of the above

Show Answer ⟶
a. local variable

29. If we want a local variable not to be deleted, then the use of the “static” keyword is a must.
a. local variable
b. global variable
c. static variable
d. All of the above

Show Answer ⟶
c. static variable

30. Which of the following datatypes does PHP support?
a. String, Integer, Float
b. Boolean
c. Array and Null
d. All of the above

Show Answer ⟶
d. All of the above

31. __ gives different output for each type of data type.
a. var_static()
b. var_datatype()
c. var_dump()
d. None of the above

Show Answer ⟶
c. var_dump()

32. How you will use single-line comments in PHP.
a. //
b. #
c. /* and */
d. Both a) and b)

Show Answer ⟶
d. Both a) and b)

33. How you will use multiple-line comments in PHP.
a. //
b. #
c. /* and */
d. Both a) and b)

Show Answer ⟶
c. /* and */

34. __ allows a programmer to make a decision based on one or more conditions and execute a piece of code conditionally.
a. If statement
b. For statement
c. While statement
d. None of the above

Show Answer ⟶
a. If statement

35. _ are used to execute the same block of code repeatedly as long as a certain condition is satisfied.
a. If statement
b. Loop statement
c. Switch statement
d. None of the above

Show Answer ⟶
b. Loop statement

36. The _ loop works only on arrays and is used to loop through each key/value pair in an array.
a. If statement
b. For loop
c. foreach loop
d. None of the above

Show Answer ⟶
c. foreach loop

37. The __ function searches for a specific text within a string and returns the character position of the first match, and if no match is found, then it will return false.
a. strrev()
b. strpos()
c. str_replace()
d. substr()

Show Answer ⟶
b. strpos()

38. The __ function replaces characters with some other characters in a string.
a. strrev()
b. strpos()
c. str_replace()
d. substr()

Show Answer ⟶
c. str_replace()

39. Which of the following functions converts the first character of each word in a string to uppercase?
a. strtoupper()
b. ucwords()
c. substr()
d. None of the above

Show Answer ⟶
b. ucwords()

40. Which of the following functions removes whitespace and other predefined characters from both sides of a string?
a. trim()
b. ucwords()
c. substr()
d. None of the above

Show Answer ⟶
a. trim()

41. Which of the following is an example of arrays?
a. Indexed arrays
b. Associative arrays
c. Multi-dimensional arrays
d. All of the above

Show Answer ⟶
d. All of the above

42. Which of the following arrays can be assigned automatically?
a. Indexed arrays
b. Associative arrays
c. Multi-dimensional arrays
d. All of the above

Show Answer ⟶
a. Indexed arrays

43. _ are arrays that use named keys instead of indexes to identify records/values.
a. Indexed arrays
b. Associative arrays
c. Multi-dimensional arrays
d. All of the above

Show Answer ⟶
b. Associative arrays

44. A _ array is an array containing one or more arrays.
a. Indexed arrays
b. Associative arrays
c. Multi-dimensional arrays
d. All of the above

Show Answer ⟶
c. Multi-dimensional arrays

45. A function name can start with a __.
a. Letter
b. Underscore
c. Both a) and b)
d. None of the above

Show Answer ⟶
c. Both a) and b)

46. Function names are NOT case sensitive.
a. True
b. False

Show Answer ⟶
a. True

47. To let a function return a value, use the return statement.
a. True
b. False

Show Answer ⟶
a. True

48. Which PHP superglobal is used to collect form data sent with the POST method?
a. $_SERVER
b. $_REQUEST
c. $_POST
d. $_GET

Show Answer ⟶
c. $_POST

49. What is the main difference between GET and POST methods in PHP?
a. Both send data in the request body.
b. GET sends data in the request body; POST sends data in the URL.
c. POST sends data in the request body; GET sends data in the URL.
d. Both send data in the URL.

Show Answer ⟶
c. POST sends data in the request body; GET sends data in the URL.

50. Which of the following is a correct way to access a POST variable named ‘username’ in PHP?
a. $username = $_SERVER[‘username’];
b. $username = $_GET[‘username’];
c. $username = $_REQUEST[‘username’];
d. $username = $_POST[‘username’];

Show Answer ⟶
d. $username = $_POST[‘username’];

51. Why is POST generally considered more secure than GET?
a. POST stores data in cookies.
b. POST encrypts data automatically.
c. POST requires HTTPS always.
d. POST hides data in the request body instead of the URL.

Show Answer ⟶
d. POST hides data in the request body instead of the URL.

52. Which HTML attribute specifies that a form should use the POST method?
a. <form type=’post’>
b. <form method=’post’>
c. <form action=’post’>
d. <form send=’post’>

Show Answer ⟶
b.

53. Which PHP superglobal is used to collect form data sent with the GET method?
a. $_SERVER
b. $_REQUEST
c. $_POST
d. $_GET

Show Answer ⟶
d. $_GET

54. Where is the data sent when using the GET method?
a. In cookies
b. In the URL as a query string
c. In the request body
d. In the HTTP headers

Show Answer ⟶
b. In the URL as a query string

55. What happens to form data when using the GET method?
a. It is displayed in the URL.
b. It is encrypted automatically.
c. It is hidden in the request body.
d. It is stored in cookies.

Show Answer ⟶
a. It is displayed in the URL.

56. Why can GET requests be bookmarked?
a. Because the data is stored in cookies
b. Because the data is part of the URL
c. Because GET encrypts the request
d. Because GET saves data on the server

Show Answer ⟶
b. Because the data is part of the URL

58. When is it appropriate to use the GET method?
a. For sending sensitive data like passwords
b. For secure transactions only
c. For uploading large files
d. For sending non-sensitive data

Show Answer ⟶
d. For sending non-sensitive data

59. Where is the data sent when using the POST method?
a. In the URL as a query string
b. In cookies
c. In the body of the HTTP request
d. In the HTTP headers

Show Answer ⟶
c. In the body of the HTTP request

60. Why can’t POST requests be bookmarked?
a. Because POST data is stored in cookies
b. Because POST data is hidden in the request body, not the URL
c. Because POST requires HTTPS
d. Because POST deletes variables after submission

Show Answer ⟶
b. Because POST data is hidden in the request body, not the URL

61. What does the following statement do?
$conn = new PDO($servername, $username, $password);

a. Creates a new SQL query
b. Creates a database connection object
c. Executes an SQL statement
d. Closes the database connection

Show Answer ⟶
b. Creates a database connection object

62. What is a cookie in PHP?
a. A file stored on the server
b. A small text file stored on the user’s computer
c. A database record
d. A session variable

Show Answer ⟶
b. A small text file stored on the user’s computer

63. Where is session data stored in PHP?
a. On the user’s computer
b. In the browser cache
c. On the server
d. In cookies only

Show Answer ⟶
c. On the server

64. Which of the following is true about cookies?
a. They are invisible to the user.
b. They are stored in the server memory.
c. They are sent along with every browser request to the server.
d. They cannot be created using PHP.

Show Answer ⟶
c. They are sent along with every browser request to the server.

65. Which of the following is an example of cookie usage?
a. Logging into Gmail and accessing YouTube
b. Storing visited pages in the browser to optimise search
c. Maintaining user information across multiple server pages
d. Encrypting passwords

Show Answer ⟶
b. Storing visited pages in the browser to optimise search

66. Which of the following is an example of session usage?
a. Saving browser history
b. Tracking visited pages locally
c. Logging into Gmail and then accessing YouTube with the same login
d. Storing search keywords in the browser

Show Answer ⟶
c. Logging into Gmail and then accessing YouTube with the same login

Disclaimer: We have provide you with the accurate handout of “Server Side Scripting PHP Class 12 MCQs“. If you feel that there is any error or mistake, please contact me at anuraganand2017@gmail.com. The above study material present on our websites is for education purpose, not our copyrights.

All the above content and Screenshot are taken from Information Technology Class 12 Textbook and MSBSHSE (HSC) Support Material which is present in MSBSHSE (HSC) website, This Textbook and Support Material are legally copyright by Maharashtra State Bureau of Textbook Production and Curriculum Research, Pune. We are only providing a medium and helping the students to improve the performances in the examination. 

Images and content shown above are the property of individual organisations and are used here for reference purposes only. To make it easy to understand, some of the content and images are generated by AI and cross-checked by the teachers. For more information, refer to the official website.

cbseskilleducation.com

Leave a Comment