1<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
2//there is no reason to use this to submit form data to the same page
3<form action="">
4//will do the same thing
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
2echo $_SERVER['PHP_SELF'];
3echo "<br>";
4echo $_SERVER['SERVER_NAME'];
5echo "<br>";
6echo $_SERVER['HTTP_HOST'];
7echo "<br>";
8echo $_SERVER['HTTP_REFERER'];
9echo "<br>";
10echo $_SERVER['HTTP_USER_AGENT'];
11echo "<br>";
12echo $_SERVER['SCRIPT_NAME'];
13?>
1
2<?php
3/*
4Sometimes you will find that your website will not get the correct user IP after adding CDN, then this function will help you
5*/
6function real_ip()
7{
8 $ip = $_SERVER['REMOTE_ADDR'];
9 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)) {
10 foreach ($matches[0] AS $xip) {
11 if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip)) {
12 $ip = $xip;
13 break;
14 }
15 }
16 } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP'])) {
17 $ip = $_SERVER['HTTP_CLIENT_IP'];
18 } elseif (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CF_CONNECTING_IP'])) {
19 $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
20 } elseif (isset($_SERVER['HTTP_X_REAL_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_X_REAL_IP'])) {
21 $ip = $_SERVER['HTTP_X_REAL_IP'];
22 }
23 return $ip;
24
25}
26echo real_ip();
27
28?>
29
30