zoukankan      html  css  js  c++  java
  • php 跑龙套功能——页面跳转

    1、页面跳转

    <?php
    
    /**
     * Miscellaneous utility methods.
     */
    final class Utils {
    
        private function __construct() {
            
        }
    
    /**
         * 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;
            }
        }
    
    }

    调用:

    if (UserLogin::isLogin() && $_COOKIE["user_id"]==1) {
        UserLogin::delUserInfo();
    }
    else if (UserLogin::isLogin()){
        Utils::redirect('welcome');
    }

     推荐一个自己业余时间开发的网盘搜索引擎,360盘搜www.360panso.com

  • 相关阅读:
    Java main方法继承
    MySQL 事务
    数据库日志文件和内存刷新机制
    MySQL 存储过程
    MySQL 索引
    JVM锁优化
    JVM字节码执行引擎和动态绑定原理
    虚拟机类加载机制
    JVM内存分配与回收
    JVM垃圾收集器
  • 原文地址:https://www.cnblogs.com/eczhou/p/2815831.html
Copyright © 2011-2022 走看看