$_SERVER

This YouTube video was created by Steve Griffith.

The $_SERVERopen in new window array contains information about the current script including headers, paths and location. The data for this array comes from the web server and is not guaranteed to be available.

Because the $_SERVER array provides data like 'SERVER_NAME' and 'SCRIPT_FILENAME', it makes it possible to write scripts that are functional regardless of the of host.

<?php
echo $_SERVER['SERVER_NAME']; // example.com
echo $_SERVER['SCRIPT_FILENAME']; // /full/path/to/script.php