Php 从文件中获取数据“获取”内容并重定向“如果”;“是”;
我还是PHP新手。如果来自的数据是Y,我想重定向用户,如果是N,则什么也不做。 我有下面的代码。不确定是否正确。那我下一步该怎么办Php 从文件中获取数据“获取”内容并重定向“如果”;“是”;,php,ip,file-get-contents,Php,Ip,File Get Contents,我还是PHP新手。如果来自的数据是Y,我想重定向用户,如果是N,则什么也不做。 我有下面的代码。不确定是否正确。那我下一步该怎么办 <?PHP // Function to get the client ip address function get_client_ip() { $ipaddress = ''; if ($_SERVER['HTTP_CLIENT_IP']) $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
<?PHP
// Function to get the client ip address
function get_client_ip() {
$ipaddress = '';
if ($_SERVER['HTTP_CLIENT_IP'])
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_X_FORWARDED'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if($_SERVER['HTTP_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if($_SERVER['HTTP_FORWARDED'])
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if($_SERVER['REMOTE_ADDR'])
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$userIP=get_client_ip();
$xml = file_get_contents("http://www.shroomery.org/ythan/proxycheck.php?ip=$userIP");
?>
谢谢。类似于
if( $xml === 'Y' )
header('Location: http://www.something.com');
请参阅,在链接头('Location:)之后使用
开关您忘记了',看起来更好一些;那工作。。谢谢,没问题。谢谢你帮我解决问题。这就是我要找的。