in ,

為什麼我的PHP 的header 無法work? 原來是這邊需要修正!

header()函式的主要功能是將HTTP協議標頭(header)輸出到瀏覽器。可以直接把頁面轉到特定你所指定的網址,如果您遇到 php 的header 轉址功能無法WORK,您可以參考如下

https://stackoverflow.com/questions/6309370/php-header-…/

的這段

i had also faced this issue many time. i solved it by putting a die(); on the next line of header(“Location: http://www.google.com“);
someting like this
header(“Location: http://www.google.com“); die();

或這裡http://php.net/manual/en/function.header.php

代碼如下

<?php
header(“Location: http://www.example.com/”); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

 

文章來源 : https://www.cloudflare.com.tw

Written by 婷Z

Generation Z,Z世代,愛網路但不沉迷網路,最愛挑戰週末脫離手機4小時

文章有用就該推一下

162 Points
Upvote Downvote
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
ISP

信箱SMTP設定! 使用各家ISP的外寄郵件伺服器發信且免帳密

cpanel主機空間使用技巧,三種方法讓你的PHP變成HTML來跑!