<legend id='6k6Um'><style id='6k6Um'><dir id='6k6Um'><q id='6k6Um'></q></dir></style></legend>

        <bdo id='6k6Um'></bdo><ul id='6k6Um'></ul>

      1. <small id='6k6Um'></small><noframes id='6k6Um'>

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

        PHP 中的命名空间阻止使用 Yii 静态函数

        时间:2023-09-24
          <tbody id='P0jww'></tbody>
        • <bdo id='P0jww'></bdo><ul id='P0jww'></ul>
        • <small id='P0jww'></small><noframes id='P0jww'>

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

          <tfoot id='P0jww'></tfoot>

            • <legend id='P0jww'><style id='P0jww'><dir id='P0jww'><q id='P0jww'></q></dir></style></legend>
                  本文介绍了PHP 中的命名空间阻止使用 Yii 静态函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我刚刚在我的小应用程序中实现了命名空间,如下所述:http://www.yiiframework.com/doc/guide/1.1/en/basics.namespace

                  I just implemented namespaces in my small application as outlined here: http://www.yiiframework.com/doc/guide/1.1/en/basics.namespace

                  我遇到了一个问题,我的控制器将不再访问 Yii::app()->getRequest(); 说它找不到 include(C:UserskuhlhtdocsinstaLabelapplicationprotectedcomponentsYii.php):无法打开流:没有那个文件或目录.

                  I'm running into an issue where my controller will no longer access Yii::app()->getRequest(); saying it can't find include(C:UserskuhlhtdocsinstaLabelapplicationprotectedcomponentsYii.php): failed to open stream: No such file or directory.

                  我意识到这是因为我将命名空间声明为应用程序/组件.但我不知道如何解决这个问题...

                  I realize that's because I declared the namespace as application/components. But I'm not sure how to work around this one...

                  <?php
                  
                  namespace applicationcomponents;
                  
                  /**
                   * Controller is the customized base controller class.
                   * All controller classes for this application should extend from this base class.
                   */
                  class Controller extends CController {
                      /* @var $request CHttpRequest */
                      protected $request = null;
                  
                      /**
                       * @var string the default layout for the controller view. Defaults to '//layouts/column1',
                       * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
                       */
                      public $layout='//layouts/column1';
                      /**
                       * @var array context menu items. This property will be assigned to {@link CMenu::items}.
                       */
                      public $menu=array();
                      /**
                       * @var array the breadcrumbs of the current page. The value of this property will
                       * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
                       * for more details on how to specify this property.
                       */
                      public $breadcrumbs=array();
                  
                      public function __construct ($id, $module = null) {
                          parent::__construct($id, $module);
                  
                          $this->request = Yii::app()->getRequest();
                      }
                  

                  推荐答案

                  你需要完全限定相对类名Yii.

                  You need to fully qualify the relative class name Yii.

                  最方便的方法是导入类:只需在命名空间声明下方添加 use Yii;.

                  The most convenient way to do this is by importing the class: just add use Yii; below your namespace declaration.

                  这篇关于PHP 中的命名空间阻止使用 Yii 静态函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Backbone Sync 返回一个空的 $_POST 数组 下一篇:查询时对相关模型的 Yii 限制

                  相关文章

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

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

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