新手问题。我希望没有人介意。
在文件 AccessesController.php
class AccessesController extends AppController {
public $name = 'Accesses';
public $helpers = array('Html', 'Form');
public function index() {
$this->aVariable = 123;
}
}
在文件 View/Accesses.ctp
<h1> You came thru the AccessesController and set
aVariable to <?php echo $this->aVariable?>, happy?</h1>
它不会在那里打印 123 。它不知道 this->aVariable 已设置为 123。
我应该使用这些全局变量Configure::read / Configure::write
吗?或者控制器和视图如何访问相同的变量?// Accesses.ctp 不知道 this->aVariable 已设置为 123。