自定义变量问题

#1 cooc123

index.php
require 'config.php';
require APP_PATH.'/lib/webconfig.php'; // 加载变量
require SP_PATH.'/SpeedPHP.php';
spRun();



function index(){

$this->webname = $webname;

$this->webkey = $webkey;

$this->weburl = $weburl;

$this->webdesc = $webdesc;

$this->Copyright = $Copyright;

$this->display("index.html");

}


为什么模板里面用 <{$webname}> 是空的

2011-10-19 14:17:23

#2 jake

$webname = 'abc';
$this->webname = $webname;

<{$webname}>

就会显示 abc

2011-10-19 14:56:13

#3 cooc123

$webname = 'abc';
$this->webname = $webname;



就会显示 abc
jake 发表于 2011-10-19 14:56
$webname 在 lib/webconfig.php 定义过了。
如果我在模板里面使用 lib/webconfig.php 里面的变量要怎么写呢

2011-10-19 15:02:32

#4 jake

在文件里面定义define("WEBNAME", 'http://localhost');

然后在模板里面<{$smarty.const.WEBNAME}>

上面是用常量的方式,另外还可以用Global全局变量的方式,这个可以上网查一下。

2011-10-19 15:06:35