META 标签 "Refresh" 替代方案 - "<?php header("Location:.. ?>": php echo in php 的问题

META Tags "Refresh" Alternative - "<?php header("Location:.. ?>": Issues with php echo in php

我正在研究如何使这段代码正常工作,但似乎无法破解它。

<?php
    header("Location: http://domain-2.com?subid=<?php echo $_GET["subid"]; ?>" /><?php
    die();
?>

我知道这与 php 中的 php 回声有关,有没有办法解决这个问题?

If none, are the below mentioned worthy contenders or is there something else that I haven't seen that would be the best choice.

这样做的目的是将用户重定向到不同的页面。 最后的 URL 看起来像这样:

http://domain-1.com/index.php?subid=subid

这将做的是它将从最终 URL 中获取子 ID 并在跟踪器应用程序上显示统计信息。 通过这样做,将不再需要更改 .php 文件中的子 ID。 我可以简单地在 .php 文件之外添加我想要跟踪的内容,只需 FTP 只需将一个文件添加到任何域即可。

我确信这段代码有效并且是我正在寻找的理想情况,但是,

<html>
    <head>
<meta http-equiv="refresh" content="0;url=http://example.com?subid=<?php echo $_GET["subid"]; ?>" />
    </head>
</html>

我研究过元刷新不适用于所有浏览器,这不好,而且这段代码:

<html>
    <head>
    <script>setTimeout('top.location = \'http://example.com?subid=<?php echo $_GET["subid"]; ?>\'', 0000);</script>
    </head>
</html>

我不确定是否会提供一个很好的选择"open for suggestions though", 它确实按照预期的方式工作,但我不完全相信这将是下一个最佳选择。

非常感谢, J.c.

您有语法错误正确的代码将是

<?php
    header("Location: http://domain-2.com?subid=".$_GET["subid"]);
    die();
?>

应该是这样的

<?php
    header("Location: http://domain-2.com?subid=".$_GET["subid"]." "); 
    die();
?>