【问题标题】:Codeigniter - Failing to load configCodeigniter - 无法加载配置
【发布时间】:2016-10-26 19:32:18
【问题描述】:

在我的代码中,根据user guide,我写了这段代码(在控制器中)

$this->config->load('countries_config.php');

但不幸的是,得到这个 PHP 错误:

遇到了 PHP 错误

严重性:通知

消息:未定义的属性:国家::$config

文件名:controllers/Countries.php

行号:12

知道为什么我不能使用配置吗?

Countries 扩展 CI_Controller

【问题讨论】:

标签: php codeigniter


【解决方案1】:

要加载您的自定义配置文件之一,您将使用以下内容 需要它的控制器中的函数:

$this->config->load('文件名');

其中 filename 是您的配置文件的名称,没有 .php 文件 扩展名。

没有 .php 扩展名

试试这个

$this->config->load('countries_config');

【讨论】:

  • @Amit 告诉你 countries_config.php 我发现文件中有错误
  • 一个班轮:$config['test'] = true;
【解决方案2】:

counteries_config.php 是这个控制器、模型或视图文件 $this->config->load('文件名');

【讨论】:

  • 这是一个配置文件
  • 然后使用 $this->config->load('filename');
  • 这就是我正在使用的
【解决方案3】:

好的,出现问题是因为我在执行parent::_construct();之前尝试加载配置文件

在之后修复

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 2013-08-10
    • 2023-02-23
    • 2011-06-14
    相关资源
    最近更新 更多