ThinkPHP? ??? MVC ?? ??? ???? ?? ?? PHP ?? ??????, ???? ??? ? ??????? ??? ??? ? ??? ????. ? ??????? ??? ? ??? ??? ??? ??? ????. ?? ?? ???? ????? ???? ? ??? ?????? ???? ???. ? ????? ThinkPHP? ???? ???? ???? ??? ?? ??? ????? ??? ?????.
1. ??? ??? ?? ThinkPHP ??
ThinkPHP? ??? ??? ?? ? ?? ?? ??? ?????:
- redirect() ??
redirect() ??? ??? URL ??? ???? ? ?????. ??? ??? ????.
redirect('url', '參數(shù)', '狀態(tài)碼')->send();
??:
- url: ????? URL ?????.
- ????: ?? ?? ???? ? ?? GET ??? ???????.
- ?? ??: ????? ?? 302, ?? ????? ?? 301? ?? HTTP ?? ?????.
?? ?? http://www.example.com/user/index ???? ????? ??? ??? ????.
redirect('http://www.example.com/user/index')->send();
- success() ? error() ??
success() ? error() ?? ???? ??? ? ???? ???? ???? ? ?????. ?? ???? ??? Success() ??? ????, ?? ???? ??? error() ??? ?????. ??? ??? ????:
success('提示信息', '跳轉(zhuǎn)URL', '等待時間')->send(); error('提示信息', '跳轉(zhuǎn)URL', '等待時間')->send();
? ?:
- ???? ??: ??? ??(??? ?? ??? ? ??).
- ?? URL : ??? URL ???, ?? ?????.
- ?? ??: ?? ??(?), ???? 1??? ?? ?????.
?? ?? ?? ???? ???? http://www.example.com/user/index ???? ????? ??? ??? ????.
success('登錄成功', 'http://www.example.com/user/index')->send();
2. ?? ??? ??? ??????
?? ???? ???? ?? ?? ??? ??? ???? ? ????. ??? ??? ?? ??? ?? ?????.
/** * 跳轉(zhuǎn)頁函數(shù) * * @param string $url 要跳轉(zhuǎn)的URL地址 * @param string $message 信息提示 * @param int $waitTime 等待時間 * @return void */ function jump($url, $message = '', $waitTime = 1) { if (empty($url)) { exit('錯誤:未指定跳轉(zhuǎn)URL地址!'); } if (!empty($message)) { $message = htmlspecialchars($message); } if ($waitTime == 0) { header("Location: {$url}"); exit; } $css = <<<EOF <style type="text/css"> .jump { text-align:center; padding-top:5%; font-family: 'Microsoft Yahei', Verdana, Arial; font-size:16px; } .jump h3 { font-size:24px; font-weight:bold; } </style> EOF; $html = <<<EOF <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>跳轉(zhuǎn)提示</title> {$css} </head> <body> <div class="jump"> <h3>跳轉(zhuǎn)提示</h3> <p>{$message}</p> <p>等待時間:<span id="wait_time">{$waitTime}</span>秒</p> <p><a href="{$url}">立即跳轉(zhuǎn)</a></p> </div> <script type="text/javascript"> var wait_time = {$waitTime}; var interval = setInterval(function(){ if(wait_time > 0) { wait_time--; document.getElementById('wait_time').innerHTML = wait_time; } else { clearInterval(interval); window.location.href = '{$url}'; } }, 1000); </script> </body> </html> EOF; echo $html; }
? ??? ??? ???? ????? ?? ??? ??? ? ????.
public function login() { if($this->request->post()){ $data = $this->request->post(); // 驗證碼驗證 $user = UserModel::where('username', $data['username'])->find(); if(!$user || $user->password != $data['password']){ jump(url('login/index'), '用戶名或密碼錯誤', 3); } else { jump(url('user/index'), '登錄成功', 3); } } return $this->fetch(); }
?? ThinkPHP? ???? ???? ???? ?? ???? ????? ???????. ??. ?? ??? ???? ?? ?????? ?? ???? ? ????.
? ??? thinkphp ?? ??? ??? ????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)