• <small id='8BjTu'></small><noframes id='8BjTu'>

        <bdo id='8BjTu'></bdo><ul id='8BjTu'></ul>

      <tfoot id='8BjTu'></tfoot>
        <i id='8BjTu'><tr id='8BjTu'><dt id='8BjTu'><q id='8BjTu'><span id='8BjTu'><b id='8BjTu'><form id='8BjTu'><ins id='8BjTu'></ins><ul id='8BjTu'></ul><sub id='8BjTu'></sub></form><legend id='8BjTu'></legend><bdo id='8BjTu'><pre id='8BjTu'><center id='8BjTu'></center></pre></bdo></b><th id='8BjTu'></th></span></q></dt></tr></i><div id='8BjTu'><tfoot id='8BjTu'></tfoot><dl id='8BjTu'><fieldset id='8BjTu'></fieldset></dl></div>
        <legend id='8BjTu'><style id='8BjTu'><dir id='8BjTu'><q id='8BjTu'></q></dir></style></legend>

        了解 PHP 的 header()

        时间:2023-11-30

      1. <i id='0wQBY'><tr id='0wQBY'><dt id='0wQBY'><q id='0wQBY'><span id='0wQBY'><b id='0wQBY'><form id='0wQBY'><ins id='0wQBY'></ins><ul id='0wQBY'></ul><sub id='0wQBY'></sub></form><legend id='0wQBY'></legend><bdo id='0wQBY'><pre id='0wQBY'><center id='0wQBY'></center></pre></bdo></b><th id='0wQBY'></th></span></q></dt></tr></i><div id='0wQBY'><tfoot id='0wQBY'></tfoot><dl id='0wQBY'><fieldset id='0wQBY'></fieldset></dl></div>
        1. <small id='0wQBY'></small><noframes id='0wQBY'>

          <legend id='0wQBY'><style id='0wQBY'><dir id='0wQBY'><q id='0wQBY'></q></dir></style></legend>
            <bdo id='0wQBY'></bdo><ul id='0wQBY'></ul>
                  <tbody id='0wQBY'></tbody>
                <tfoot id='0wQBY'></tfoot>

                1. 本文介绍了了解 PHP 的 header()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  你在哪里使用命令 header()?

                  我在 handlers/handle_login.php 中有以下代码.用户从 index.php 进入站点,这是起始位置.

                  I have the following code at handlers/handle_login.php. The user has gone to the site from index.php which is the starting place.

                   if(!$logged_in){
                       header("Location: index.php");                                                                          
                       die("You are not logged_in");
                   }
                  

                  如果 if-clause 为真,我会收到 404 错误,因为标题将我转到 handlers/index.php,而不是 index.php.

                  If if-clause is true, I get a 404 error, since the header puts me to to handlers/index.php, instead of index.php.

                  推荐答案

                  虽然我同意尼拉莫和伯爵的观点,但我希望我能给出更大的图景:

                  While I agree with nilamo and earl, I hope I can give a bigger picture:

                  使用相对路径可能会产生非常奇怪的效果,具体取决于浏览器的位置认为"它在您的站点层次结构中.例如,假设站点有一个索引文件/index.php",但配置为接受 URI 路径中的模块和操作.您可能有一个如下所示的网址:

                  Using relative paths can have very strange effects depending on where the browser 'thinks' it is in your site hierarchy. For example, assume the site has an index file '/index.php' but is configured to accept module and action in the URI path. You may very well have a url that looks like:

                  http://www.yoursite.com/forms/contact/
                  

                  从这种情况下,返回一个像这样的标题:

                  From this situation, returning a header like:

                  header("Location: index.php");
                  

                  很可能会导致浏览器尝试请求

                  may very well cause the browser to try to request

                  http://www.yoursite.com/forms/contact/index.php
                  

                  这显然不是你想要的.出于这个原因,通常最好使用上面推荐的/index.php",或者尽可能使用完全限定的 URL.

                  which is obviously not what you want. For this reason, it's generally better to use '/index.php' as recommended above, or even better use the fully qualified URL when possible.

                  希望这会有所帮助.

                  这篇关于了解 PHP 的 header()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:主题或消息中包含特殊字符的电子邮件的 PHP 邮件标头 下一篇:如何获取响应标头?

                  相关文章

                    <tfoot id='15bf5'></tfoot>
                  1. <legend id='15bf5'><style id='15bf5'><dir id='15bf5'><q id='15bf5'></q></dir></style></legend>

                    <small id='15bf5'></small><noframes id='15bf5'>

                      • <bdo id='15bf5'></bdo><ul id='15bf5'></ul>

                    1. <i id='15bf5'><tr id='15bf5'><dt id='15bf5'><q id='15bf5'><span id='15bf5'><b id='15bf5'><form id='15bf5'><ins id='15bf5'></ins><ul id='15bf5'></ul><sub id='15bf5'></sub></form><legend id='15bf5'></legend><bdo id='15bf5'><pre id='15bf5'><center id='15bf5'></center></pre></bdo></b><th id='15bf5'></th></span></q></dt></tr></i><div id='15bf5'><tfoot id='15bf5'></tfoot><dl id='15bf5'><fieldset id='15bf5'></fieldset></dl></div>