0
0
PHPprogramming~30 mins

$_SERVER information in PHP - Mini Project: Build & Apply

Choose your learning style9 modes available
Exploring $_SERVER Information in PHP
📋 What You'll Learn
💡 Why This Matters
🌍 Real World
Web developers often need to check server environment details to debug or customize website behavior based on server or client information.
💼 Career
Understanding $_SERVER helps in backend web development, troubleshooting server issues, and writing dynamic PHP applications that respond to request details.
Progress0 / 4 steps
1
Create the initial $_SERVER keys list
Create a variable called keys_to_show and set it to an array with these exact strings: 'SERVER_NAME', 'SERVER_SOFTWARE', 'REQUEST_METHOD', 'SCRIPT_NAME', 'HTTP_USER_AGENT'.
PHP
Need a hint?

Use square brackets [] to create an array with the exact keys listed.

2
Initialize the server_info array
Create an empty associative array called server_info to hold the selected $_SERVER information.
PHP
Need a hint?

Use = [] to create an empty array.

3
Fill server_info with selected $_SERVER data
Use a foreach loop with variable key to iterate over keys_to_show. Inside the loop, set server_info[key] to the value from $_SERVER[key] if it exists, or to the string 'Not set' if it does not.
PHP
Need a hint?

Use the null coalescing operator ?? to provide a default value if the $_SERVER key is missing.

4
Print the server_info contents
Use a foreach loop with variables key and value to iterate over server_info. Inside the loop, print each key and value in the format: key: value followed by a newline.
PHP
Need a hint?

Use echo to print each key and value with a colon and newline.