PHP header('location: mypage.php') 对比 header('location : mypage.php')
PHP header('location: mypage.php') vs header('location : mypage.php')
我对 PHP 有一些基础知识。一旦我的 Localhost (XAMPP) 出现 500 内部错误,它表明服务器过载。经过一些研发后,我得到了解决方案。
我用过
header('location : mypage.php') // Giving me 500 internal error
解决方案是
header('location: mypage.php') // just removing the space between 'location' and ':'
所以我的问题是为什么会这样?
'location : mypage.php' 和 'location: mypage.php' 有什么区别?
很简单,包含 space 时语法错误。它是规范的一部分,您可以在 W3C 网站上阅读。
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
我对 PHP 有一些基础知识。一旦我的 Localhost (XAMPP) 出现 500 内部错误,它表明服务器过载。经过一些研发后,我得到了解决方案。
我用过
header('location : mypage.php') // Giving me 500 internal error
解决方案是
header('location: mypage.php') // just removing the space between 'location' and ':'
所以我的问题是为什么会这样? 'location : mypage.php' 和 'location: mypage.php' 有什么区别?
很简单,包含 space 时语法错误。它是规范的一部分,您可以在 W3C 网站上阅读。
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30