新手初次学习框架,提问。
发布于:2022-01-17 09:50:54
#1 苏城
这是放置在根目录的
config.inc.php 文件内容
"config" => array
'name' => 'SpeedPHP', //网站名称
'ue' => 'PHP快速开发框架', // 网站标语
),
tpl文件目录中
index.html 文件
如何这样用{<$now.name>}网站名称,这样用{<$now.ue>} 网站标语
{<$now.name $now.ue>>}
大致就是这个意思,文本里面的怎么调用?看了数据库哪个,不知道文本如何调用?
2014-05-22 17:54:14
#2 jake
在控制器构造函数里面,取得你的config文件里面的数据,然后直接赋值给模板,类似下面的代码:
class xxx extends spController{
function __construct(){
parent::__construct();
$this->now = require(APP_PATH."/config.php");
}
}
);
2014-05-22 18:24:59
#3 苏城
在 controller 文件夹,main.php 文件中
class main extends spController
{
function index(){
$tpl = $this->spArgs("tpl", "Public")
$tiez = spClass("tiez");
$this->results = $tiez->findAll();
$this->display("{$tpl}/index.html");
function __construct(){
parent::__construct();
$this->now = require(APP_PATH."/config.inc.php");
}
}
}
在 tpl/Public 文件夹,index.html 文件中
<{$now.name}>根本没作任何反映
config.inc.php文件是这样的
$config = array(
'name' => 'SpeedPHP', //网站名称
'ue' => 'PHP快速开发框架' // 网站标语
);
2014-05-22 21:18:50
#4 jake
稍微理解一下这样的做法,这里是
$this->now = require(APP_PATH."/config.inc.php");
你的config.inc.php文件如果是
$config = array(
'name' => 'SpeedPHP', //网站名称
'ue' => 'PHP快速开发框架' // 网站标语
);
这样,那么就需要
require(APP_PATH."/config.inc.php");
$this->now = $config;
还有,构造函数怎么放,请先看看php手册了解一下吧。
2014-05-23 08:40:09
#5 苏城
在快速入门,Hello word中你介绍了用连接可以访问controller中不同文件中的动作。但是你没介绍直接echo
2014-05-25 14:36:01
#6 jake
{:soso_e179:}不明觉厉啊
2014-05-25 22:28:41