PHP功能类[获取客户端IP、页面跳转]
2012-12-18 14:27
691 查看
<?php /** * Miscellaneous utility methods. */ final class Utils { private function __construct() { } /** * Get IP address * @return string IP address string */ public static function getIpAddress() { return $_SERVER["REMOTE_ADDR"]; } /************************************************* 华丽的分割线 ************************************************/ /** * Redirect to the given page. * @param type $page target page * @param array $params page parameters */ public static function redirect($page, $sub_page = null, array $params = array()) { header('Location: ' . self::createLink($page, $sub_page, $params)); die(); } /** * Generate link. * @param string $page target page * @param array $params page parameters */ public static function createLink($page, $sub_page = null, array $params = array()) { if ($sub_page) { $params = array_merge(array('sub_page' => $sub_page), $params); } if (!$page) { return "#"; } $param_str = http_build_query($params); if (trim($param_str) == "") { return $page . '.php'; } else { return $page . '.php?' . $param_str; } } } // Get IP Address. $last_login_ip = Utils::getIpAddress(); // Redirect to the given page. Utils::redirect('welcome'); ?>
相关文章推荐
- php获取页面地址(带GET参数)、客户端ip、服务器端ip
- PHP如何获取客户端真实IP
- PHP获取客户端和服务器端IP
- PHP获取客户端的真实IP
- PHP获取用户客户端真实IP的解决方案
- 配置Nginx方向代理后,php获取客户端真实IP
- PHP如何获取客户端真实IP
- JAVA/PHP服务器端获取客户端IP
- PHP获取客户端IP的方法
- php获取客户端ip
- PHP获取客户端的IP
- PHP获取访客IP、地区位置信息、浏览器、来源页面
- PHP获取客户端和服务器端IP
- PHP获取客户端与服务器IP
- php获取客户端IP和服务器端IP
- PHP实现获取客户端IP并获取IP信息
- PHP获取客户端真实IP
- 深入分析几种PHP获取客户端IP的情况
- Nginx反向代理导致PHP获取不到正确的HTTP_HOST,SERVER_NAME,客户端IP的解决方法
- html中的a标签用js来实现页面跳转的功能(php分页时做的页面跳转)