Php Super Global Variable

Variables that you can access from any part of your code is called global variable. In Php, you can not create global variable but PHP use some variable that act like as super global variable.

There are some superglobal variables

$_ENV[]:-This is an array that contains environment variables.


<?php
print_r($_ENV);
?>

$_GET[]:- This is an array and holds all of the GET variables gathered from the user’s web browser.


<?php
print_r($_GET);
?>

$_POST[] – This is an array and holds all of the POST variables gathered from the user’s web browser.


<?php
print_r($_POST);
?>

$_SERVER[] – This kind of array holds the values of web-server variables.


<?php
print_r($_SERVER)
?>

It will show all web server variables value like HTTP_HOST, HTTP_CONNECTION, etc.

Php Super Global Variable – Interview Questions

Q 1: What are superglobals in PHP?

Ans: Predefined variables accessible everywhere in a script.

Q 2: Name some PHP superglobals.

Ans: $_GET, $_POST, $_SESSION, $_COOKIE.

Q 3: Are superglobals case-sensitive?

Ans: Yes.

Q 4: Can superglobals be used inside functions?

Ans: Yes, without using global.

Q 5: Why are superglobals useful?

Ans: They manage request data and environment info.

Php Super Global Variable – Objective Questions (MCQs)

Q1. Which of the following is a superglobal variable?






Q2. Superglobals are available ______.






Q3. $_GET is used to retrieve data from ______.






Q4. $_POST retrieves data sent via ______.






Q5. $GLOBALS contains ______.






Related Php Super Global Variable Topics