Exploring $_SERVER
The $_SERVER superglobal is an array in PHP that contains information about headers, paths, and script locations. It is populated by the web server and provides useful details about the current request and server environment. Some of the most common keys you will use include:
server_info.php
12345678910111213141516<?php // Print server name echo "Server Name: " . $_SERVER['SERVER_NAME'] . "<br>"; // Print request method echo "Request Method: " . $_SERVER['REQUEST_METHOD'] . "<br>"; // Print script name echo "Script Name: " . $_SERVER['SCRIPT_NAME'] . "<br>"; // Print server software echo "Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "<br>"; // Print HTTP host echo "HTTP Host: " . $_SERVER['HTTP_HOST'] . "<br>"; ?>
The name of the server host under which the current script is executing.
The request method used to access the page, such as GET or POST.
The path of the current script relative to the document root.
The web server identification string, like "Apache/2.4.41 (Unix)".
The host header from the current request.
These keys are especially useful for debugging, logging, and building dynamic applications that need to adapt to different server environments or respond to specific requests. For example, you might use REQUEST_METHOD to check if a form was submitted via POST, or use SCRIPT_NAME to generate links relative to the current script.
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 5
Exploring $_SERVER
Desliza para mostrar el menú
The $_SERVER superglobal is an array in PHP that contains information about headers, paths, and script locations. It is populated by the web server and provides useful details about the current request and server environment. Some of the most common keys you will use include:
server_info.php
12345678910111213141516<?php // Print server name echo "Server Name: " . $_SERVER['SERVER_NAME'] . "<br>"; // Print request method echo "Request Method: " . $_SERVER['REQUEST_METHOD'] . "<br>"; // Print script name echo "Script Name: " . $_SERVER['SCRIPT_NAME'] . "<br>"; // Print server software echo "Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "<br>"; // Print HTTP host echo "HTTP Host: " . $_SERVER['HTTP_HOST'] . "<br>"; ?>
The name of the server host under which the current script is executing.
The request method used to access the page, such as GET or POST.
The path of the current script relative to the document root.
The web server identification string, like "Apache/2.4.41 (Unix)".
The host header from the current request.
These keys are especially useful for debugging, logging, and building dynamic applications that need to adapt to different server environments or respond to specific requests. For example, you might use REQUEST_METHOD to check if a form was submitted via POST, or use SCRIPT_NAME to generate links relative to the current script.
¡Gracias por tus comentarios!