如何将值传递给header()函数?

时间:2012-05-27 20:12:20

标签: php parsing header

我必须将用户重定向到不同的页面。 所以这就是我现在所拥有的。

header('Location: http://www.example.com/$confirmpage')

但它不起作用。它将它们重定向到http://www.example.com/ $ confirmpage(未检索到的值。)并给出404错误。

当我使用

echo "<script>document.location='http://www.example.com/$confirmpage';</script>";

有效。

但由于某些原因,我必须使用header()函数。

1 个答案:

答案 0 :(得分:5)

header("Location: http://www.example.com/$confirmpage")

如果要在php字符串中引用变量,则必须使用"而不是'

http://php.net/manual/en/language.types.string.php

相关问题