php用静态类实现的页面跳转
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Libérer: 2016-07-25 09:07:45
original
1132 Les gens l'ont consulté
-
-
/**
- * 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');
- }
- ?>
复制代码
|
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Derniers articles par auteur
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
Derniers numéros
-
2025-03-21 13:39:34
-
2025-03-21 13:38:34
-
2025-03-21 13:37:19
-
2025-03-21 13:35:24
-
2025-03-21 13:34:32