【问题标题】:php : my header function didn't work.php :我的标头功能不起作用。
【发布时间】:2016-03-04 08:48:22
【问题描述】:

我的标题功能不起作用。 我创建了 2 页 test 和 test2

测试中的所有代码:

<?php 
//header('Location ../index.php');
  header("Location ./test2.php"); ?>

页面test2中的所有代码

<?php   echo 'hello';    ?>

为什么我的功能不起作用?前面没有回声,这是最大的问题。这就是这两个页面中的所有代码。

谢谢

【问题讨论】:

  • 你知道浏览器控制台里面的网络标签吗?
  • 这是调用header函数的正确方法:: header('Location: example.com/');
  • 此代码回显 aaaaaa 但标头功能不起作用。 if((!(isset($_SESSION['logged-in'])))){ header('Location: ../index.php'); echo 'aaaaaaaaaaa'; }

标签: php netbeans printing header


【解决方案1】:

你的语法错误,应该是(注意:):

<?php 
  header("Location: ./test2.php"); 
?>

如果文件在那里,它应该可以工作。确保路径是正确的,目前你有它指向同一个目录

【讨论】:

  • 哦,是的,对不起。在主代码中我有一个问题,不想移动所以我不得不创建这些页面作为测试,看看它是否有效。我的主要代码中的下一步是检查 echo :) 谢谢
猜你喜欢
  • 1970-01-01
  • 2018-10-29
  • 1970-01-01
  • 2013-07-04
  • 1970-01-01
  • 2015-02-26
  • 1970-01-01
  • 2011-08-20
  • 1970-01-01
相关资源
最近更新 更多