<tfoot id='OUjav'></tfoot>
        <legend id='OUjav'><style id='OUjav'><dir id='OUjav'><q id='OUjav'></q></dir></style></legend>

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

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

        • <bdo id='OUjav'></bdo><ul id='OUjav'></ul>

        PHP 命名空间和内置类的问题,如何解决?

        Problems with PHP namespaces and built-in classes, how to fix?(PHP 命名空间和内置类的问题,如何解决?)

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

          • <bdo id='8Pezp'></bdo><ul id='8Pezp'></ul>

                    <tbody id='8Pezp'></tbody>

                  <small id='8Pezp'></small><noframes id='8Pezp'>

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

                  问题描述

                  我正在用 PHP 编写一个小型库,但我遇到了一些无法读取内置类的问题.例如:

                  I'm writing a small library in PHP and i'm having some problems with built-in classes not being read. For example:

                  namespace Woody;
                  
                  class Test {
                    public function __construct() {
                      $db = new PDO(params);
                    }
                  }
                  

                  这给了我:

                  PHP 致命错误:在/var/www/test.php 中找不到类WoodyPDO"

                  PHP Fatal error: Class 'WoodyPDO' not found in /var/www/test.php

                  推荐答案

                  这个:

                  namespace Woody;
                  use PDO;
                  

                  或者:

                  $db = new PDO(params);
                  

                  以防万一,类 PDO 不是您命名空间中的全限定名称,因此 PHP 会查找不可用的 WoodyPDO.

                  Point in case is, that the class PDO is not a full qualified name within your Namespace, so PHP would look for WoodyPDO which is not available.

                  请参阅 名称解析规则文档 详细说明如何将类名解析为完全限定名.

                  See Name resolution rulesDocs for a detailed description how class names are resolved to a Fully qualified name.

                  这篇关于PHP 命名空间和内置类的问题,如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How do I parse XML containing custom namespaces using SimpleXML?(如何使用 SimpleXML 解析包含自定义命名空间的 XML?)
                  SimpleXML SOAP response Namespace issues(SimpleXML SOAP 响应命名空间问题)
                  Use php namespace inside function(在函数内部使用 php 命名空间)
                  unexpected #39;use#39; (T_USE) when trying to use composer(尝试使用作曲家时意外的“使用(T_USE))
                  PHP adding custom namespace using autoloader from composer(PHP使用来自作曲家的自动加载器添加自定义命名空间)
                  How to use composer packages in codeigniter?(如何在 codeigniter 中使用作曲家包?)
                2. <legend id='QsdgX'><style id='QsdgX'><dir id='QsdgX'><q id='QsdgX'></q></dir></style></legend>

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

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

                        <tfoot id='QsdgX'></tfoot>