1echo $_SERVER['PHP_SELF'];
2echo "<br>";
3echo $_SERVER['SERVER_NAME'];
4echo "<br>";
5echo $_SERVER['HTTP_HOST'];
6echo "<br>";
7// echo $_SERVER['HTTP_REFERER'];
8echo "<br>";
9echo $_SERVER['HTTP_USER_AGENT'];
10echo "<br>";
11echo $_SERVER['SCRIPT_NAME'];
1//Just a PHP file to put on your local server (as I don't have enough memory)
2// Write the code by Md Abdur Rakib
3
4<?php
5$indicesServer = array('PHP_SELF',
6'argv',
7'argc',
8'GATEWAY_INTERFACE',
9'SERVER_ADDR',
10'SERVER_NAME',
11'SERVER_SOFTWARE',
12'SERVER_PROTOCOL',
13'REQUEST_METHOD',
14'REQUEST_TIME',
15'REQUEST_TIME_FLOAT',
16'QUERY_STRING',
17'DOCUMENT_ROOT',
18'HTTP_ACCEPT',
19'HTTP_ACCEPT_CHARSET',
20'HTTP_ACCEPT_ENCODING',
21'HTTP_ACCEPT_LANGUAGE',
22'HTTP_CONNECTION',
23'HTTP_HOST',
24'HTTP_REFERER',
25'HTTP_USER_AGENT',
26'HTTPS',
27'REMOTE_ADDR',
28'REMOTE_HOST',
29'REMOTE_PORT',
30'REMOTE_USER',
31'REDIRECT_REMOTE_USER',
32'SCRIPT_FILENAME',
33'SERVER_ADMIN',
34'SERVER_PORT',
35'SERVER_SIGNATURE',
36'PATH_TRANSLATED',
37'SCRIPT_NAME',
38'REQUEST_URI',
39'PHP_AUTH_DIGEST',
40'PHP_AUTH_USER',
41'PHP_AUTH_PW',
42'AUTH_TYPE',
43'PATH_INFO',
44'ORIG_PATH_INFO') ;
45
46echo '<table cellpadding="10">' ;
47foreach ($indicesServer as $arg) {
48 if (isset($_SERVER[$arg])) {
49 echo '<tr><td>'.$arg.'</td><td>' . $_SERVER[$arg] . '</td></tr>' ;
50 }
51 else {
52 echo '<tr><td>'.$arg.'</td><td>-</td></tr>' ;
53 }
54}
55echo '</table>' ;
56
57/*
58
59That will give you the result of each variable like (if the file is server_indices.php at the root and Apache Web directory is in E:\web) :
60
61PHP_SELF /server_indices.php
62argv -
63argc -
64GATEWAY_INTERFACE CGI/1.1
65SERVER_ADDR 127.0.0.1
66SERVER_NAME localhost
67SERVER_SOFTWARE Apache/2.2.22 (Win64) PHP/5.3.13
68SERVER_PROTOCOL HTTP/1.1
69REQUEST_METHOD GET
70REQUEST_TIME 1361542579
71REQUEST_TIME_FLOAT -
72QUERY_STRING
73DOCUMENT_ROOT E:/web/
74HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
75HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.3
76HTTP_ACCEPT_ENCODING gzip,deflate,sdch
77HTTP_ACCEPT_LANGUAGE fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
78HTTP_CONNECTION keep-alive
79HTTP_HOST localhost
80HTTP_REFERER http://localhost/
81HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
82HTTPS -
83REMOTE_ADDR 127.0.0.1
84REMOTE_HOST -
85REMOTE_PORT 65037
86REMOTE_USER -
87REDIRECT_REMOTE_USER -
88SCRIPT_FILENAME E:/web/server_indices.php
89SERVER_ADMIN myemail@personal.us
90SERVER_PORT 80
91SERVER_SIGNATURE
92PATH_TRANSLATED -
93SCRIPT_NAME /server_indices.php
94REQUEST_URI /server_indices.php
95PHP_AUTH_DIGEST -
96PHP_AUTH_USER -
97PHP_AUTH_PW -
98AUTH_TYPE -
99PATH_INFO -
100ORIG_PATH_INFO -
101
102*/
103?>
104
1<?php
2 // PHP $_SERVER['...']; method
3
4 // PHP file name
5 echo 'PHP file name: '.$_SERVER['PHP_SELF'].'<br>';
6 // Server name
7 echo 'Server name: '.$_SERVER['SERVER_NAME'].'<br>';
8 // HTTP host
9 echo 'HTTP host: '.$_SERVER['HTTP_HOST'].'<br>';
10 // Refering link
11 echo 'Refering link: '.$_SERVER['HTTP_REFERER'].'<br>';
12 // User agent
13 echo 'User agent: '.$_SERVER['HTTP_USER_AGENT'].'<br>';
14 // Script name
15 echo 'Script name: '.$_SERVER['SCRIPT_NAME'];
16
17 // The rest is optional
18
19 if($_SERVER['PHP_SELF']=='/filename.php'){
20 //If there is no folder
21 echo 'No folder'.$_SERVER['PHP_SELF'];
22 } else{
23 // Echo the name of the folder containing the PHP file
24 echo 'PHP file name: '.$_SERVER['PHP_SELF'];
25 }
26
27 // The same if statements can be used for the script name
28
29 if($_SERVER['SCRIPT_NAME']=='/filename.php'){
30 // If there is no folder
31 echo 'No folder'.$_SERVER['SCRIPT_NAME'];
32 } else{
33 // Echo the name of the folder containing the PHP file
34 echo 'PHP file name: '.$_SERVER['SCRIPT_NAME'];
35 }
36
37 echo '<a href="repl.it/@CoolWebDev">More from me...</a>';
38
39 // I hope you found this helpful!
40?>