1
新手問題。我希望沒有人介意。在cakePHP中,控制器設置View的訪問權限的最佳方式是什麼?
在文件AccessesController.php
class AccessesController extends AppController {
public $name = 'Accesses';
public $helpers = array('Html', 'Form');
public function index() {
$this->aVariable = 123;
}
}
在文件瀏覽/ 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不知道這個 - > aVariable已被設置爲123