PHP Predefined Variables

Example 1: PHP_SELF

The current PHP file is: /infost440/a3/predefined.php

$_SERVER["PHP_SELF"] contains the path and filename of the currently running PHP script.

Example 2: REQUEST_METHOD

The request method is: GET

$_SERVER["REQUEST_METHOD"] tells PHP which HTTP request method was used to access the page, such as GET or POST.

What Are Predefined Variables?

Predefined variables are variables that PHP automatically provides to a program. They contain useful information about the server, request, environment, and other parts of the PHP program. They are useful because programmers can access this information without creating the values themselves.