PHP Superglobals

PHP Superglobals

Several predefined variables in PHP are "superglobals", which means they are always accessible, regardless of scope - and you can access them from any function, class, or file without having to do anything special.


The PHP Superglobal Variables

Example: Using $_SERVER

Let's look at $_SERVER to find the name of the file currently executing.

Example

<?php
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
?>

Superglobals are the essential bridge between the user's web browser and the server!