English 中文(简体)
• 如何使《准则》中的所有控制人员都能获得变数?
原标题:How to make variables accessible in all controllers in Codeigniter?

我在“CI-主计长”类别下添加了一些变量,如:

$data[ foo ] =  bar ;
$data[ animal ] =  dog ;
$data[ justin_beiber ] =  terrible ;

自2006年以来 我希望这些变量能够在我的所有控制者手中,而且由于所有控制者都延伸到这个控制中心。 主计长,我估计这项工作将:

echo $data[ foo ];
die();

我将此事带入一名主计长兼主计长。 但它并没有产生任何结果。 如何做到这一点?

最佳回答

或许适当利用组合方案将有助于你。

rel=“nofollow” http://codeigniter.com/user_guide/libraries/config.html

你可以把 CI结构中任何地方的混淆起来。

并且根据您的变量的推测, 你们可以把保护var带给一个阶层,让他们从继承中看到,但我不认为这是这样做的最佳途径。 至少不了解为什么你不使用助手在任何地方都想要获得数据。

问题回答




相关问题
Subclass check, is operator or enum check

A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...

C++ Class Inheritance problem

Hi I have two classes, one called Instruction, one called LDI which inherits from instruction class. class Instruction{ protected: string name; int value; public: Instruction(string ...

Overloading a method in a subclass in C++

Suppose I have some code like this: class Base { public: virtual int Foo(int) = 0; }; class Derived : public Base { public: int Foo(int); virtual double Foo(double) = 0; }; ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

Extending Flex FileReference class to contain another property

I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn t let me pass arguments to functions through event listeners, which makes me feel sad,...

Interface Inheritance in C++

I have the following class structure: class InterfaceA { virtual void methodA =0; } class ClassA : public InterfaceA { void methodA(); } class InterfaceB : public InterfaceA { virtual ...