############################################################################### # 轉向函數 # $url:網址 # $time:時間 # $message:訊息 # $error:ture false => 當true 時,則頁面會轉向 message.php ############################################################################### function redirect_header($url = "", $time = 3000, $message = '已轉向!!',$error='') { $_SESSION['redirect'] = "\$.jGrowl(\"{$message}\", { life:{$time} , position: 'center', speed: 'slow' });"; $_SESSION['error'] = $error ? $message :""; $url = $error ? WEB_URL . "/message.php":$url; header("location:{$url}"); exit; } ``` 三、使用時機 1. 通知:redirect\_header("index.php", 3000, "您沒有管理員權限!"); 2. 通知:redirect\_header($\_SESSION\['returnUrl'\], 3000, $msg); 3. 資料庫執行失敗:$db->query($sql) or redirect\_header("", 3000, $db->error."\\n".$sql ,ture);