在我的申请,我已经设置类似配置的变量在core.php中如在根目录文件读取配置变量
core.php中
$websetting = array(
'mydomain' => $_SERVER['HTTP_HOST'],
'adminEmail' => '[email protected]',
'supportEmail' => '[email protected]',
'infoEmail' => '[email protected]',
'accountEmail' => '[email protected]',
'facebook' => 'facebook.com/xyz',
'twitter' => 'twitter.com/@xyz'
);
Configure::write('WebsiteSetting', $websetting);
现在我创建一个morning.php在webroot中的cj文件。所以我的路径是这样的:webroot/cj/morning.php
在morning.php我试着读Configure::read('WebsiteSetting.mydomain')
。
<?php
echo Configure::read('WebsiteSetting.mydomain');
?>
发生了什么事:
使用框架。创建一个你想要的控制器/动作/视图。不要试图发明一些东西。没有快速简单的方法来实现这一点,并且可以通过“正确”方式轻松实现。 – Ross