1. <small id='Do0Q0'></small><noframes id='Do0Q0'>

  2. <tfoot id='Do0Q0'></tfoot>

      <bdo id='Do0Q0'></bdo><ul id='Do0Q0'></ul>

    1. <i id='Do0Q0'><tr id='Do0Q0'><dt id='Do0Q0'><q id='Do0Q0'><span id='Do0Q0'><b id='Do0Q0'><form id='Do0Q0'><ins id='Do0Q0'></ins><ul id='Do0Q0'></ul><sub id='Do0Q0'></sub></form><legend id='Do0Q0'></legend><bdo id='Do0Q0'><pre id='Do0Q0'><center id='Do0Q0'></center></pre></bdo></b><th id='Do0Q0'></th></span></q></dt></tr></i><div id='Do0Q0'><tfoot id='Do0Q0'></tfoot><dl id='Do0Q0'><fieldset id='Do0Q0'></fieldset></dl></div>
      <legend id='Do0Q0'><style id='Do0Q0'><dir id='Do0Q0'><q id='Do0Q0'></q></dir></style></legend>
    2. 如何从 PHP 脚本发送 500 Internal Server Error 错误

      How to send 500 Internal Server Error error from a PHP script(如何从 PHP 脚本发送 500 Internal Server Error 错误)
      <legend id='K1MOs'><style id='K1MOs'><dir id='K1MOs'><q id='K1MOs'></q></dir></style></legend>

            1. <tfoot id='K1MOs'></tfoot>

              <small id='K1MOs'></small><noframes id='K1MOs'>

                <tbody id='K1MOs'></tbody>
            2. <i id='K1MOs'><tr id='K1MOs'><dt id='K1MOs'><q id='K1MOs'><span id='K1MOs'><b id='K1MOs'><form id='K1MOs'><ins id='K1MOs'></ins><ul id='K1MOs'></ul><sub id='K1MOs'></sub></form><legend id='K1MOs'></legend><bdo id='K1MOs'><pre id='K1MOs'><center id='K1MOs'></center></pre></bdo></b><th id='K1MOs'></th></span></q></dt></tr></i><div id='K1MOs'><tfoot id='K1MOs'></tfoot><dl id='K1MOs'><fieldset id='K1MOs'></fieldset></dl></div>
                <bdo id='K1MOs'></bdo><ul id='K1MOs'></ul>
                本文介绍了如何从 PHP 脚本发送 500 Internal Server Error 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I need to send "500 Internal Server Error" from an PHP script under certain conditions. The script is supposed to be called by a third party app. The script contains a couple of die("this happend") statements for which I need to send the 500 Internal Server Error response code instead of the usual 200 OK. The third party script will re-send the request under certain conditions which include not receiving the 200 OK response code.

                Second part of the question: I need to setup my script like this:

                <?php
                    custom_header( "500 Internal Server Error" );
                
                    if ( that_happened ) {
                        die( "that happened" )
                    }
                
                    if ( something_else_happened ) {
                        die( "something else happened" )
                    }
                
                    update_database( );
                
                    // the script can also fail on the above line
                    // e.g. a mysql error occurred
                
                    remove_header( "500" );
                ?>
                

                I need to send 200 header only after the last line has been executed.

                Edit

                A side question: can I send strange 500 headers such as these:

                HTTP/1.1 500 No Record Found
                HTTP/1.1 500 Script Generated Error (E_RECORD_NOT_FOUND)
                HTTP/1.1 500 Conditions Failed on Line 23
                

                Will such errors get logged by the webserver?

                解决方案

                header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
                

                这篇关于如何从 PHP 脚本发送 500 Internal Server Error 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)

                <small id='DrMa2'></small><noframes id='DrMa2'>

                • <bdo id='DrMa2'></bdo><ul id='DrMa2'></ul>
                    <tfoot id='DrMa2'></tfoot>

                      <tbody id='DrMa2'></tbody>

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

                        1. <legend id='DrMa2'><style id='DrMa2'><dir id='DrMa2'><q id='DrMa2'></q></dir></style></legend>