php referer url
$_SERVER['HTTP_REFERER'];
php server name
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
echo "<br>";
echo $_SERVER['HTTP_HOST'];
echo "<br>";
// echo $_SERVER['HTTP_REFERER'];
echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
$_Server php
<?php
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
echo "<br>";
echo $_SERVER['HTTP_HOST'];
echo "<br>";
echo $_SERVER['HTTP_REFERER'];
echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
?>
php server function
<?php
// PHP $_SERVER['...']; method
// PHP file name
echo 'PHP file name: '.$_SERVER['PHP_SELF'].'<br>';
// Server name
echo 'Server name: '.$_SERVER['SERVER_NAME'].'<br>';
// HTTP host
echo 'HTTP host: '.$_SERVER['HTTP_HOST'].'<br>';
// Refering link
echo 'Refering link: '.$_SERVER['HTTP_REFERER'].'<br>';
// User agent
echo 'User agent: '.$_SERVER['HTTP_USER_AGENT'].'<br>';
// Script name
echo 'Script name: '.$_SERVER['SCRIPT_NAME'];
// The rest is optional
if($_SERVER['PHP_SELF']=='/filename.php'){
//If there is no folder
echo 'No folder'.$_SERVER['PHP_SELF'];
} else{
// Echo the name of the folder containing the PHP file
echo 'PHP file name: '.$_SERVER['PHP_SELF'];
}
// The same if statements can be used for the script name
if($_SERVER['SCRIPT_NAME']=='/filename.php'){
// If there is no folder
echo 'No folder'.$_SERVER['SCRIPT_NAME'];
} else{
// Echo the name of the folder containing the PHP file
echo 'PHP file name: '.$_SERVER['SCRIPT_NAME'];
}
echo '<a href="repl.it/@CoolWebDev">More from me...</a>';
// I hope you found this helpful!
?>
php $_SERVER
<?php
/*
Sometimes you will find that your website will not get the correct user IP after adding CDN, then this function will help you
*/
function real_ip()
{
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) {
foreach ($matches[0] AS $xip) {
if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip)) {
$ip = $xip;
break;
}
}
} elseif (isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CF_CONNECTING_IP'])) {
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
} elseif (isset($_SERVER['HTTP_X_REAL_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_X_REAL_IP'])) {
$ip = $_SERVER['HTTP_X_REAL_IP'];
}
return $ip;
}
echo real_ip();
?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us