Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试通过http等效重定向时出错_Php_Redirect - Fatal编程技术网

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">'; 
}