Using Predefined Variables in PHP

Server Name: mail.wdchiesa.soisweb.uwm.edu

GET Variable (name): Guest

Explanation

Predefined variables in PHP, also known as superglobals, are built-in variables that are always accessible, regardless of scope. Examples include $_SERVER, which contains information about the server and environment, and $_GET, which retrieves variables sent via the HTTP GET method. These variables are useful for accessing server data and user input without requiring explicit definition within the script.

Source Code

<?php
// Using $_SERVER predefined variable
$server_name = $_SERVER['SERVER_NAME'];
echo "<p>Server Name: $server_name</p>";

// Using $_GET predefined variable
// Assume the URL is something like predefined.php?name=John
$name = isset($_GET['name']) ? $_GET['name'] : 'Guest';
echo "<p>GET Variable (name): $name</p>";
?>