Print Shortlink

$_SERVER PHP Variable usages with example

$_SERVER in PHP is very useful to getting lot of information about the PHP script in execution as well as the server/request details. $_SERVER is containing information such as headers, paths, and script locations. The entries(values)  in this array are created by the web server.

1.$_SERVER[‘PHP_SELF’]

This php variable used to get currently executing script, relative to the document root. This variable returns currently executing script.

2. $_SERVER[‘REMOTE_ADDR’]

This php variable used to get remote ip address. That is, it used to get client ip address. It return client IP Address.

3. $_SERVER[‘SERVER_ADDR’]

This php variable used to get  server ip address. we can get executing server ip address.

4. $_SERVER[‘REQUEST_URI’]

This variable use to make request server. The actual URI used in HTTP protocol (after GET or POST) to make the request.

5. $_SERVER[”HTTP_USER_AGENT’]

This variable used to get client browser details like to check which browser using client.

Share this!!!!!!!!!!!!!!!!

Leave a Reply


− 2 = three

Read previous post:
PHP directory listing script

I here explained to list the directory files using php (server side scripting language).   <?php    function list_files($dir) {...

Close