Server-Side PHP: Part 2: $_SERVER

Server-Side PHP

PHP is a programming language frequently used for server-side web development.


$_SERVER is one of several superglobal variables that exist in PHP that can be used in server-side operations. In order to know things like the server port or name, this variable can be accessed.

As the PHP manual page warnings, some server environments may not populate certain values. However, those like SERVER_NAME, REMOTE_ADDR, and REMOTE_HOST can be depended on to have values regardless of server environment.

As reviewed in the last part, the values inside of $_SERVER can be seen through using a foreach loop to iterate through each key-value pair within it to generate a HTML table, mixing both HTML and a section enclosed within PHP short tags.