A PHP Superglobals Quiz tests your knowledge of built-in global variables that are accessible from anywhere in a PHP script.
Question 1
What is the purpose of the $GLOBALS
superglobal in PHP?
To store session data
To access global variables from anywhere in the script
To manage uploaded files
To handle cookies
Question 2
Which PHP superglobal holds information about headers, paths, and script locations?
$_COOKIE
$_SESSION
$_SERVER
$_FILES
Question 3
What is the main difference between $_POST
and $_GET
superglobals?
$_POST
sends data via URL; $_GET
sends data via body
$_POST
hides form data; $_GET
appends data to the URL
$_POST
is slower than $_GET
$_POST
can only send numeric data; $_GET
sends text
Question 4
Which superglobal is used to collect form data submitted via HTTP POST method?
$_GET
$_POST
$_REQUEST
$_SESSION
Question 5
How does PHP allow access to global variables inside functions without using the global
keyword?
Using $_POST
Using $GLOBALS
Using $_SERVER
Using $_SESSION
Question 6
What type of data does $_FILES
Superglobal handle?
Session data
Server environment variables
Uploaded file information
URL parameters
Question 7
Which superglobal variable stores cookie information sent by the browser?
$_SESSION
$_COOKIE
$_REQUEST
$_ENV
Question 8
How do you retrieve environment variables in PHP?
Using $_ENV
Using $_SERVER
Using $_SESSION
Using $_COOKIE
Question 9
Can $_SESSION
be accessed without starting a session in PHP?
Yes, always accessible
No, must call session_start()
first
Only in command-line scripts
Only when cookies are enabled
Question 10
What happens if you use $_SERVER['HTTP_HOST']
in a PHP script?
Returns the server's IP address
Returns the Host header, usually the domain name of the request
Returns the script file name
Returns the browser type
There are 10 questions to complete.