php - 代码点火器和配置文件中的自定义库?

标签 php codeigniter configuration-files libraries

我在代码点火器中有一个库,看起来像 class MyClass($options = array())

文件是Myclass.php

我有一个文件 (config/Myclass.php) 看起来像

$Myclass = array(
  'something' => 'value',
  'another'   => 'value'
);

当我初始化我的类时,我认为应该传递 $Myclass 数组,但显然不是?

我需要做什么来修复它?

最佳答案

啊,我找到了答案,

配置文件中的数组必须被称为$config

文件名也必须是库文件名的小写表示。

例如

库文件:Somelibrary.php
LIB 内容:class Somelibrary($options = array()){...
配置文件:somelibrary.php
配置内容:$config = array('something' => 'value');

关于php - 代码点火器和配置文件中的自定义库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6103056/

相关文章:

spring - 特定于机器的 webapp 配置

php - 我如何访问 localhost/phpmyadmin 因为我一整天都无法访问此站点?

c# - 如何在 .NET C# 中转换反序列化 php 对象

php - echo 中的 if !empty 表达式

php - 使用 'type' 列识别表的行

php - 如何将完整的 POST 发送到 Codeigniter 中的模型

maven - Jenkins CI : Where and how store configuration files?

php - 将 Excel 上传到 MySql 数据库时排除行

php - URI 路由不起作用(多语言)

c# - .net 跨应用程序配置设置