如果输出到其他地方,则显示PhP
所以我得到了这个代码:如果输出到其他地方,则显示PhP,php,Php,所以我得到了这个代码: <?php $host = "http://$_SERVER[HTTP_HOST]"; $rd = "/beta/"; $beta = "<font color='#6034b1'>BETA</font>"; if(isset($_COOKIE["fg_beta_user"]) && $_COOKIE["fg_beta_user"]){ header('Refresh:10;' . $host.
<?php
$host = "http://$_SERVER[HTTP_HOST]";
$rd = "/beta/";
$beta = "<font color='#6034b1'>BETA</font>";
if(isset($_COOKIE["fg_beta_user"]) && $_COOKIE["fg_beta_user"]){
header('Refresh:10;' . $host.$rd);
echo "<center>You are member of the $beta Project<br>You will be redirected in:<div id='countdown'>10</div><br><progress value='0' max='9' id='progressBar'></progress></center>";}
else {
echo "<center>You are not a Member of our $beta Project!<br><a style='border-bottom:1px solid black;' href='switch-to-beta.php'>JOIN NOW</a>";
}
?>
是的,您可以将消息设置为变量
if (YOUR STATEMENT HERE) {
header();
$message = "your message";
else {
$message = "another message";
}
然后在以后的HTML中,您可以打开另一个PHP标记并回显变量
<p><?php echo $message; ?></p>
在页面的其他位置显示消息非常简单
<?php
$host = "http://$_SERVER[HTTP_HOST]";
$rd = "/beta/";
$beta = "<font color='#6034b1'>BETA</font>";
if(isset($_COOKIE["fg_beta_user"]) && $_COOKIE["fg_beta_user"]){
header('Refresh:10;' . $host.$rd);
$message = "<center>You are member of the " . $beta . " Project<br>You will be redirected in:<div id='countdown'>10</div><br><progress value='0' max='9' id='progressBar'></progress></center>";
}
else {
$message = "<center>You are not a Member of our " . $beta . "Project!<br><a style='border-bottom:1px solid black;' href='switch-to-beta.php'>JOIN NOW</a>";
}
?>
有。只需更改您的echo“…”
到$out=“…”:
并执行回显$out代码>你想要它的地方。为什么不试试呢?@MagnusEriksson因为这只会显示变量的输出。如果你按照我的建议做,它不会显示语句的输出,而不是echo“hello”
,do$out=“hello”;echo$输出代码>,它将产生完全相同的结果。不同之处在于,您可以将echo$输出代码>你想要在文件中的任何位置。但正如你可能看到的那样。我用2个回声。这意味着我不能告诉你我需要显示哪两个回声是的,你用一个变量赋值代替两个回声,使用相同的变量。然后,当您进一步向下回显时,它将包含正确的消息。这两个答案都是正确的。我建议你尝试一下,如果可行的话,接受其中一个。
<?php
echo $message;
?>