6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【PHP】header関数でリダイレクト先URLに変数を使う方法

Last updated at Posted at 2018-09-06

PHPのheader関数、リダイレクト先を変数にするときの書き方をよく忘れるのでメモ。

location.php
// 変数にリダイレクト先URLを格納する(パラメータ付きURLにリダイレクトさせる想定)
$id = "abc";
$url = "http://hogehoge.com/?id=" . $id;

// これでhttp://hogehoge.com/?id=abcにリダイレクトされる。
header("Location:" . $url );

// exit()は忘れないように!
exit();
6
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?