php
  • parsing
  • header
  • 2012-05-27 93 views 0 likes 
    0

    我必须将用户重定向到不同的页面。 所以这里是我现在拥有的。如何将值传递给header()函数?

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

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

    当我使用

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

    它的工作原理。

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

    +1

    取决于'$ confirmpage'的内容,您可能希望['用urlencode '](http://php.net/urlencode)它。 –

    回答

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

    如果你想REFFERENCE在PHP字符串变量,你必须使用"代替'

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

    +0

    感谢它的工作。 – Visualizer7

    +1

    它说可以在5分钟内接受答案。 – Visualizer7

    相关问题