Restoration
8/6/2016 - 3:30 PM

PHPの環境変数

PHPの環境変数

<!DOCTYPE>
<html>
<head>
    <meta charset="utf-8">
    <title>Test</title>
</head>
<body>
<?php

function h($var){
	if(is_array($var)){
		return array_map('h',$var);
	} else {
		return htmlspecialchars( $var,ENT_QUOTES,'UTF-8');
	}
}

$agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SREVER['HTTP_USER_AGENT'] : '';
$ip = issset($_SEREVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '' ;
$ref = isset($_SEREVER['HTTP_REFERER']) ? $_SEREVER['HTTP_REFERER'] : '';

echo 'ブラウザ' .h($agent). '<br />';
echo 'IPアドレス' .h($ip).'<br />';
echo '参照元' .h('$ref').'<br />';

echo '<pre>';
var_dump(h($_SERVER));
echo '</pre>';
?>
</body>
</html>