Php 尝试通过http等效重定向时出错
这是我的密码:Php 尝试通过http等效重定向时出错,php,redirect,Php,Redirect,这是我的密码: if ( $A=="3" ) { <meta http-equiv="\refresh\" content=\"0; url=http://ex.com/"> } if($A==“3”){ } 错误: Parse error: syntax error, unexpected '<' in /home/ex/public_html/sy.php on line 94 Parse error:syntax error,unexpected'问题已明确指出,
if ( $A=="3" ) {
<meta http-equiv="\refresh\" content=\"0; url=http://ex.com/">
}
if($A==“3”){
}
错误:
Parse error: syntax error, unexpected '<' in /home/ex/public_html/sy.php on line 94
Parse error:syntax error,unexpected'问题已明确指出,您使用它的方式有一个',PHP将继续执行,页面将不会重定向,直到客户端浏览器执行HTML元标记。也许这就是你想要它做的,但如果不是,这可能是一个更好的解决方案
if ($A == "3")
die(header("Location: http://ex.com/"));
否则,正如其他海报已经指出的那样,您需要echo
:
if ($A == "3")
echo "<meta http-equiv=\"refresh\" content=\"0; url=http://ex.com/\">";
if($A==“3”)
回声“;
问题在于
是html。因此,您必须使用echo语句将其打印出来,而不是像这样写
<meta http-equiv="\refresh\" content=\"0; url=http://ex.com/">
if ( $A=="3" ) {
echo '<meta http-equiv="refresh" content="0; url=http://ex.com">';
}
if($A==“3”){
回声';
}
<meta http-equiv="\refresh\" content=\"0; url=http://ex.com/">
if ( $A=="3" ) {
echo '<meta http-equiv="refresh" content="0; url=http://ex.com">';
}