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<?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?>