Created
August 6, 2016 15:30
-
-
Save Restoration/557739ba761607133edcad622989e855 to your computer and use it in GitHub Desktop.
PHPの環境変数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment