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

    <bdo id='bJbly'></bdo><ul id='bJbly'></ul>
<legend id='bJbly'><style id='bJbly'><dir id='bJbly'><q id='bJbly'></q></dir></style></legend>

<tfoot id='bJbly'></tfoot>

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

        Laravel 如何处理 PHP 警告?

        How Laravel handles PHP warnings?(Laravel 如何处理 PHP 警告?)
      1. <small id='B5xlQ'></small><noframes id='B5xlQ'>

          <tfoot id='B5xlQ'></tfoot>

          1. <legend id='B5xlQ'><style id='B5xlQ'><dir id='B5xlQ'><q id='B5xlQ'></q></dir></style></legend>
            • <bdo id='B5xlQ'></bdo><ul id='B5xlQ'></ul>
              • <i id='B5xlQ'><tr id='B5xlQ'><dt id='B5xlQ'><q id='B5xlQ'><span id='B5xlQ'><b id='B5xlQ'><form id='B5xlQ'><ins id='B5xlQ'></ins><ul id='B5xlQ'></ul><sub id='B5xlQ'></sub></form><legend id='B5xlQ'></legend><bdo id='B5xlQ'><pre id='B5xlQ'><center id='B5xlQ'></center></pre></bdo></b><th id='B5xlQ'></th></span></q></dt></tr></i><div id='B5xlQ'><tfoot id='B5xlQ'></tfoot><dl id='B5xlQ'><fieldset id='B5xlQ'></fieldset></dl></div>
                  <tbody id='B5xlQ'></tbody>

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

                  问题描述

                  我正在尝试使用 Laravel 连接到 LDAP 服务器.重要的是要说我正在使用 PHP 函数 ldap_connectldap_bind 而不是使用包来处理它.

                  I'm trying to connect to a LDAP server using Laravel. It is important to say that I'm using the PHP functions ldap_connect and ldap_bind instead of using a package to handle it.

                  关键是当我提供错误的用户名和密码时,ldap_bind 函数会给我们一个 PHP 警告.我可以接受这个警告,并且正如文档中所述,当绑定没有发生时,该函数返回 false.

                  The point is that when I provide wrong user and password, the ldap_bind function gives to us a PHP warning. I'm OK with this warning and, as is in the documentation, the function returns false when the bind does not occur.

                  但是,当这个警告被触发时,Laravel 会抛出一个异常.这不是异常,Laravel 不应该抛出异常,我不想将其作为异常处理;我只需要构建一个 if 条件,它将向用户返回一条消息.

                  But, Laravel is throwing an exception when this warning is triggered. This is not an exception, Laravel should not throw an exception and I wouldn't like to handle this as an exception; I just have to build an if condition that will return a message to the user.

                  Laravel 是否将所有警告都视为异常?

                  Does Laravel catch all warnings as an Exception?

                  推荐答案

                  这是 Laravel 的预期行为.Laravel 会将任何错误转换为 ErrorException 实例.这是 bootstrap() 方法L42" rel="nofollow noreferrer">Illuminate/Foundation/Bootstrap/HandleExceptions.php 类.

                  This is the intended behavior for Laravel. Laravel will turn any error into an ErrorException instance. Here's the bootstrap() method inside the Illuminate/Foundation/Bootstrap/HandleExceptions.php class.

                  public function bootstrap(Application $app)
                  {
                      $this->app = $app;
                  
                      error_reporting(-1);
                  
                      set_error_handler([$this, 'handleError']);
                  
                      set_exception_handler([$this, 'handleException']);
                  
                      register_shutdown_function([$this, 'handleShutdown']);
                  
                      if (! $app->environment('testing')) {
                          ini_set('display_errors', 'Off');
                      }
                  }
                  

                  error_reporting(-1); 将设置 PHP 报告所有错误(阅读更多 这里).

                  The error_reporting(-1); will set PHP to report all errors (read more here).

                  虽然这部分代码:

                  set_error_handler([$this, 'handleError']);
                  

                  将设置自定义错误处理程序.如果检查 handleError() 方法,很明显 Laravel 会将任何错误转换为 ErrorException 实例.

                  Will set a custom error handler. If you check the handleError() method, it's pretty clear that Laravel will turn any error into an ErrorException instance.

                  public function handleError($level, $message, $file = '', $line = 0, $context = [])
                  {
                      if (error_reporting() & $level) {
                          throw new ErrorException($message, 0, $level, $file, $line);
                      }
                  }
                  

                  阅读更多关于用户定义的错误处理程序这里.

                  Read more about user-defined error handler here.

                  希望这能把事情弄清楚.:)

                  Hope this clear things up. :)

                  这篇关于Laravel 如何处理 PHP 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  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 的问题)
                      <tbody id='hH4U5'></tbody>
                        <tfoot id='hH4U5'></tfoot>
                      • <small id='hH4U5'></small><noframes id='hH4U5'>

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

                          <legend id='hH4U5'><style id='hH4U5'><dir id='hH4U5'><q id='hH4U5'></q></dir></style></legend>