0
0
PHPprogramming~5 mins

$_SERVER information in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the $_SERVER variable in PHP?

$_SERVER is a superglobal array in PHP that contains information about headers, paths, and script locations. It provides details about the server environment and the current request.

Click to reveal answer
beginner
What does $_SERVER['REQUEST_METHOD'] represent?

It shows the HTTP method used to access the page, such as GET or POST. This tells you how the user sent data to the server.

Click to reveal answer
intermediate
Explain $_SERVER['HTTP_USER_AGENT'].

This contains information about the user's browser or client software. It helps identify what device or browser the visitor is using.

Click to reveal answer
beginner
What information does $_SERVER['SERVER_NAME'] provide?

It gives the name of the server host that is running the script, usually the domain name or IP address.

Click to reveal answer
intermediate
How can $_SERVER['SCRIPT_FILENAME'] be useful?

It shows the full path and filename of the currently executing script. This helps when you need to know exactly where your PHP file is located on the server.

Click to reveal answer
Which $_SERVER key contains the IP address of the client?
ASERVER_ADDR
BHTTP_USER_AGENT
CREMOTE_ADDR
DSERVER_NAME
What does $_SERVER['REQUEST_URI'] represent?
AThe client's browser type
BThe full URL of the current page
CThe server's root directory
DThe URI which was given to access the page
Which $_SERVER key tells you the HTTP method used (GET, POST, etc.)?
AHTTP_METHOD
BREQUEST_METHOD
CMETHOD_TYPE
DSERVER_METHOD
If you want to know the name of the script currently running, which $_SERVER key do you use?
ASCRIPT_NAME
BSCRIPT_FILENAME
CPHP_SELF
DSERVER_NAME
What does $_SERVER['HTTP_REFERER'] contain?
AThe URL of the previous page that linked to the current page
BThe IP address of the server
CThe user's browser language
DThe server software version
Describe what kind of information you can get from the $_SERVER array in PHP and why it might be useful.
Think about what the server and browser tell your PHP script during a request.
You got /5 concepts.
    Explain how you would use $_SERVER['REQUEST_METHOD'] in a PHP script that handles form submissions.
    Consider how forms send data and how your script knows when to act.
    You got /4 concepts.