我想在CakePHP中创建一个全局变量。如果我在app_controller.php中定义一些内容,例如
var $varName
我可以访问
$this->varName
从我的任何 Controller 中获取,但是我无法从模型中获取。
如何创建可从模型访问的全局变量?
$ varName的值直到运行时才知道,所以我不认为bootstrap.php是一个选项。
最佳答案
CakePHP’s new Configure class can be used to store and retrieve application or runtime specific values. Be careful, this class allows you to store anything in it, then use it in any other part of your code
关于cakephp - 在CakePHP中创建全局变量的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/639564/