<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 警告?

        时间:2024-08-23
      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 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从 mod_php 查看 PHP 的 ldap_* 函数的标准错误(LDAP_OPT_DEBUG_LEVEL=7) 下一篇:LDAP 绑定似乎返回 true,密码为空

                  相关文章

                    <tfoot id='hH4U5'></tfoot>
                  1. <small id='hH4U5'></small><noframes id='hH4U5'>

                    • <bdo id='hH4U5'></bdo><ul id='hH4U5'></ul>
                  2. <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>