zoukankan      html  css  js  c++  java
  • PHP功能类[获取客户端IP、页面跳转]

    <?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');


    ?>
  • 相关阅读:
    个人期末总结
    团队冲刺第二阶段10
    团队冲刺第二阶段9
    团队冲刺第二阶段8
    团队冲刺第二阶段7
    团队冲刺第二阶段6
    数据分析之例题
    数据分析之数据操作
    数据分析之Matplotlib可视化
    数据分析之Pandas
  • 原文地址:https://www.cnblogs.com/setsail/p/2823231.html
Copyright © 2011-2022 走看看