server variables in php code example
Example: php server function
<?php
echo 'PHP file name: '.$_SERVER['PHP_SELF'].'<br>';
echo 'Server name: '.$_SERVER['SERVER_NAME'].'<br>';
echo 'HTTP host: '.$_SERVER['HTTP_HOST'].'<br>';
echo 'Refering link: '.$_SERVER['HTTP_REFERER'].'<br>';
echo 'User agent: '.$_SERVER['HTTP_USER_AGENT'].'<br>';
echo 'Script name: '.$_SERVER['SCRIPT_NAME'];
if($_SERVER['PHP_SELF']=='/filename.php'){
echo 'No folder'.$_SERVER['PHP_SELF'];
} else{
echo 'PHP file name: '.$_SERVER['PHP_SELF'];
}
if($_SERVER['SCRIPT_NAME']=='/filename.php'){
echo 'No folder'.$_SERVER['SCRIPT_NAME'];
} else{
echo 'PHP file name: '.$_SERVER['SCRIPT_NAME'];
}
echo '<a href="repl.it/@CoolWebDev">More from me...</a>';
?>