Predefined Variables

Back to index

$_SERVER['SERVER_NAME']

asifkhan.soisweb.uwm.edu

This variable shows the name of the server that is running the website. In my example, it shows the server name for my UWM website. It can be useful when I want PHP to know which server or website is handling the current request.

$_SERVER['PHP_SELF']

/infost440/a3/predefined.php

This variable shows the path and name of the PHP file that is currently being used. In this example, it shows the location of predefined.php. It can help identify the current PHP page that is running.

$_SERVER['HTTP_USER_AGENT']

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

This variable gives information about the browser or program that made the request to the website. It can include information about the browser, device, and operating system. It is useful for understanding how a visitor reached the PHP page.

Explanation

Predefined variables are variables that PHP provides automatically. I do not have to create them myself. SERVER_NAME gives the server name, PHP_SELF shows the current file, and HTTP_USER_AGENT gives information about the browser or program making the request. These variables can be useful when working with websites.