header()与exit的可选语法之间的差异


difference between alternative syntax of header() with exit

我很想知道之间有什么区别吗

header('Location:index.php'); // using  capital  `L`
exit(); // using parenthesis

header('location:index.php');
exit;

我们应该推荐使用哪一种?

根据HTTP的实际RFC,您应该使用大写的"L";,和一个绝对URI:

header('Location: http://www.mysite.com/index.php');

exitexit()而言,没有差异。它是一种语言构造,而不是函数,括号是可选的。您甚至可以使用exit 0exit(0)

退出之间没有区别;和exit();

并且Location应该用大写的L 来书写