Displaying server variables

I need help display certain server variables

below is my code

[php]<?php
error_reporting(0); // turn error messages off
echo “AUTH_TYPE: When running under Apache as module doing HTTP authenticated, this variable holds the authentication type.”; // prints definition of AUTH_TYPE
echo “

”;
echo $_SERVER[‘AUTH_TYPE’];
echo “

”;
echo “DOCUMENT_ROOT: The document root directory under which the script is executing, as defined in the server’s configuration file.”;
echo “

”;
echo $_SERVER[‘DOCUMENT_ROOT’];
echo “

”;
echo “GATEWAY_INTERFACE: What revision of the CGI specification the server is using; such as ‘CGI/1.1’.”;
echo “

”;
echo $_SERVER[‘GATEWAY_INTERFACE’];
echo “

”;
echo “PATH_TRANSLATED: File system-based path to the current script.”;
echo “

”;
echo $_SERVER[‘PATH_TRANSLATED’];
echo “

”;
echo “PHP_AUTH_PW: When running under Apache as module doing HTTP authentication, this variable holds the password provided by the user.”;
echo “

”;
echo $_SERVER[‘PHP_AUTH_PW’];
echo “

”;
echo “PHP_AUTH_USER: When running under Apache as module doing HTTP authentication, this variable holds the username provided by the user.”;
echo “

”;
echo $_SERVER[‘PHP_AUTH_USER’];
echo “

”;
echo “PHP_SELF: The filename of the currently executing script, relative to the document root.”;
echo “

”;
echo $_SERVER[‘PHP_SELF’];
echo “

”;
echo “QUERY_STRING: The query string, if there was any, with which the page was accessed.”;
echo “

”;
echo $_SERVER[‘QUERY_STRING’];
echo “

”;
echo “REMOTE_ADDR: The IP address from which the user is viewing the current page.”;
echo “

”;
echo $_SERVER[‘REMOTE_ADDR’];
echo “

”;
echo “REMOTE_HOST: The Host name from which the user is viewing the current page.”;
echo “

”;
echo $_SERVER[‘REMOTE_HOST’];
echo “

”;
echo “REMOTE_PORT: The port being used on the user’s machine to communicate with the Web server.”;
echo “

”;
echo $_SERVER[‘REMOTE_PORT’];
echo “

”;
echo “REQUEST_METHOD: Specifies which request method was used to access the page; such as ‘GET’, ‘HEAD’, ‘POST’, ‘PUT’.”;
echo “

”;
echo $_SERVER[‘REQUEST_METHOD’];
echo “

”;
echo “REQUEST_URI: The URI which was given in order to access this page, such as ‘/index.html’.”;
echo “

”;
echo $_SERVER[‘REQUEST_URI’];
echo “

”;
echo “SCRIPT_FILENAME: The abosolute pathname of the currently executing script.”;
echo “

”;
echo $_SERVER[‘SCRIPT_FILENAME’];
echo “

”;
echo “SCRIPT_NAME: Contains the current script’s path. This is useful for pages that need to point to themselves.”;
echo “

”;
echo $_SERVER[‘SCRIPT_NAME’];
echo “

”;
echo “SERVER_ADMIN: The value given to the SERVER_ADMIN (for apache) directive in the Web server configuration file.”;
echo “

”;
echo $_SERVER[‘SERVER_ADMIN’];
echo “

”;
echo “SERVER_NAME: The name of the server host under which the script is executing.”;
echo “

”;
echo $_SERVER[‘SERVER_NAME’];
echo “

”;
echo “SERVER_PORT: The port on the server machine being used by the web server for communication. By default setup, this is ‘80’.”; // prints definition of SERVER_PORT
echo “

”;
echo $_SERVER[‘SERVER_PORT’];
echo “

”;
echo “SERVER_PROTOCOL: Name and revision of the information protocol via which the page was requested; such as ‘HTTP / 1.0’.”; // prints definition of SERVER_PROTOCOL
echo “

”;
echo $_SERVER[‘SERVER_PROTOCOL’];
echo “

”;
echo “SERVER_SIGNATURE: String containing ther server version and virtual host name, which are added to server-generated pages.”; // prints definition of SERVER_SIGNATURE
echo “

”;
echo $_SERVER[‘SERVER_SIGNATURE’]; // check!
echo “

”;
echo “SERVER_SOFTWARE: The server identification string.”; // prints definition of SERVER_SOFTWARE
echo “

”;
echo $_SERVER[‘SERVER_SOFTWARE’];

?>[/php]

Below is the output:

AUTH_TYPE: When running under Apache as module doing HTTP authenticated, this variable holds the authentication type.

DOCUMENT_ROOT: The document root directory under which the script is executing, as defined in the server’s configuration file.

C:/wamp/www/

GATEWAY_INTERFACE: What revision of the CGI specification the server is using; such as ‘CGI/1.1’.

CGI/1.1

PATH_TRANSLATED: File system-based path to the current script.

PHP_AUTH_PW: When running under Apache as module doing HTTP authentication, this variable holds the password provided by the user.

PHP_AUTH_USER: When running under Apache as module doing HTTP authentication, this variable holds the username provided by the user.

PHP_SELF: The filename of the currently executing script, relative to the document root.

/server.php

QUERY_STRING: The query string, if there was any, with which the page was accessed.

REMOTE_ADDR: The IP address from which the user is viewing the current page.

127.0.0.1

REMOTE_HOST: The Host name from which the user is viewing the current page.

REMOTE_PORT: The port being used on the user’s machine to communicate with the Web server.

51176

REQUEST_METHOD: Specifies which request method was used to access the page; such as ‘GET’, ‘HEAD’, ‘POST’, ‘PUT’.

GET

REQUEST_URI: The URI which was given in order to access this page, such as ‘/index.html’.

/server.php

SCRIPT_FILENAME: The abosolute pathname of the currently executing script.

C:/wamp/www/server.php

SCRIPT_NAME: Contains the current script’s path. This is useful for pages that need to point to themselves.

/server.php

SERVER_ADMIN: The value given to the SERVER_ADMIN (for apache) directive in the Web server configuration file.

admin@localhost

SERVER_NAME: The name of the server host under which the script is executing.

localhost

SERVER_PORT: The port on the server machine being used by the web server for communication. By default setup, this is ‘80’.

80

SERVER_PROTOCOL: Name and revision of the information protocol via which the page was requested; such as ‘HTTP / 1.0’.

HTTP/1.1

SERVER_SIGNATURE: String containing ther server version and virtual host name, which are added to server-generated pages.

SERVER_SOFTWARE: The server identification string.

Apache/2.2.17 (Win32) PHP/5.3.5

As you can see its prints all the server variables except, AUTH_TYPE, PATH_TRANSLATED, PHP_AUTH_PW, PHP_AUTH_USER, QUERY_STRING, REMOTE_HOST, SERVER_SIGNATURE.

If I turn error reporting on, I get an undefined index error for these variables

I need help to display these variables

Any assitance will be appreciated

Thanks

Hi there,

This is because they’ll only be set if they have a value. The auth related ones are used for HTTP authentication. QUERY_STRING requires the page you’re calling this from to have some GET vars. Not used all of them, but a quick Google of their names should tell you what they’re for and why they’re not set by default.

Sponsor our Newsletter | Privacy Policy | Terms of Service