What are Super Global Variables in PHP? | 7+ MCQ Questions and Answers on Superglobal Variable

Some predefined variables in PHP are “superglobals”, meaning of superglobal is that they are always accessible at any location. They are accessible inside and outside the scope. You can access them from any function, class, or file without doing anything special. This means there is no need for any permission to call variables anywhere. Now let’s start with What are Super Global Variables in PHP? Reading carefully about super global variables is a very important concept for a Software Developer.

Join to Become PHP Web Developer - Future Scope Career Guidance

WhatsApp Group Join Now
Telegram Group Join Now
Follow On Instagram Follow Us

How to Create Super Global Variables in PHP?

Superglobal variables are prefixed with the $_ (underscore followed by a name in uppercase) and are case-sensitive.

List of Super Global Variables in PHP

  • $_GET: This superglobal variable is used to collect data sent to the script via the HTTP GET method. It is often used to retrieve query parameters from the URL.
  • $_POST: Used for collecting data sent via the HTTP POST method, typically from HTML forms. It is crucial for processing user-submitted data securely.
  • $_REQUEST: Combines data from $_GET, $_POST, and $_COOKIE. It provides a convenient way to access data regardless of the HTTP request method used.
  • $_SESSION: This superglobal variable is essential for managing user sessions. It allows you to store and retrieve data that persists across multiple page requests, maintaining state and user-specific information.
  • $_COOKIE: Used for handling HTTP cookies sent by the client’s browser. It enables you to read and set cookies, which can be used to remember user preferences or track user interactions.
  • $_SERVER: Contains information about the server environment, including details about the current script, server name, client user agent, and more. It’s valuable for customizing responses based on server and client attributes.
  • $_GLOBALS: Provides access to all global variables in PHP. You can use this to modify and access variables from outside the current scope, although it is generally considered good practice to minimize the use of global variables.
  • $_FILES: Used to access information about files uploaded via HTML forms. It contains details about the uploaded file, such as its name, type, and location.
  • $_ENV: Contains environment variables defined on the server. This is useful when dealing with server-specific configurations or settings.

Which superglobal variable provides information about the client’s browser and operating system?

  1. $_BROWSER
  2. $_USER_AGENT
  3. $_SERVER
  4. $_CLIENT_INFO

Answer: 3. $_SERVER


Which superglobal variable is used to set and access cookies in PHP?

  1. $_COOKIE
  2. $_SESSION
  3. $_REQUEST
  4. $_GET

Answer: 1. $_COOKIE

Check out the Latest Top MCQ Array of Logical Questions for Freshers, featuring 10 PHP.


Which superglobal variable is used to access session data in PHP?

  1. $_SESSION
  2. $_COOKIE
  3. $_POST
  4. $_GET

Answer: 1. $_SESSION


Which superglobal variable in PHP stores form input data submitted via the POST method?

  1. $_POST
  2. $_GET
  3. $_REQUEST
  4. $_SESSION

Answer: 1. $_POST


Which superglobal variable contains information about the current URL and its components?

  1. $_SERVER
  2. $_URL
  3. $_REQUEST
  4. $_ENV

Answer: 1. $_SERVER


Which superglobal variable is used to retrieve query parameters from the URL?

  1. $_GET
  2. $_POST
  3. $_REQUEST
  4. $_QUERY

Answer: 1. $_GET


Which superglobal variable is used to retrieve the HTTP request method, such as GET or POST?

  1. $_REQUEST_METHOD
  2. $_METHOD
  3. $_REQUEST_TYPE
  4. $_HTTP_METHOD

Answer: 1. $_REQUEST_METHOD


Which superglobal variable is used to store data submitted via both GET and POST methods?

  1. $_GET_POST
  2. $_REQUEST
  3. $_INPUT
  4. $_BOTH

Answer: 2. $_REQUEST

Difference Between Margin and Padding in CSS | 3 Important Differences


Which superglobal variable is used to access server-related information, such as server name and script filename?

  1. $_SERVER
  2. $_HOST
  3. $_SCRIPT
  4. $_ENV

Answer: 1. $_SERVER


Which superglobal variable is used to access global variables and functions defined outside the current scope?

  1. $_GLOBALS
  2. $_GLOBAL
  3. $_SYSTEM
  4. $_OUTER

Answer: 1. $_GLOBALS


Follow Us on Social Media

Follow Quiz Lancer Telegram Channel to solve daily interview questions. We share important interview questions which are asked in the interview. Most of the students get good values from this channel and got selected as a developer.


FAQ on Super Global Variables in PHP

  1. Which of the following is not a super global variable in PHP?

    $_LOCAL is NOT a super global variable in PHP.

  2. What is another name for a global variable?

    The set of all global variables is known as the global environment or global state.

  3. What is the difference between a local variable and a global variable?

    Local variables are created when the function starts its execution and are lost when the function ends. Global variables, on the other hand, are created as the execution of the program begins and are lost when the program is ended.

  4. Can global variables be used in function?

    Global variables can be used by everyone, both inside of functions and outside.

86 / 100
Scroll to Top