Smarty调用问题。

php中文网
发布: 2016-06-06 20:51:03
原创
1390人浏览过

运行网页空白一片,不知道是不是哪里没有引用正确

所有的文件夹在同一个目录下面

AI建筑知识问答
AI建筑知识问答

用人工智能ChatGPT帮你解答所有建筑问题

AI建筑知识问答 181
查看详情 AI建筑知识问答

我自己的项目包含目前如下几个文件夹

/Smarty

/smarty_cache 这个文件是我单独创建的

/templates 这个文件是我单独创建的

/templates_c 这个文件是我单独创建的

三个文件 /index.php /smarty.inc.php /templates/index.cpl

其中index.php中的内容如下:

1	<?php
2	 
3	include('smarty.inc.php');
4	$smarty->assign('kaishi','这个不知到怎么样,测试看看!');
5	$smarty->display('index.cpl');
6	 
7	?>
登录后复制

smarty.inc.php中的代码如下:

01	<?php
02	include_once("./Smarty/Smarty.class.php");//包含smarty类文件
03	$smarty=new Smarty();//建立Smarty实例对象$smarty
04	$smarty->config_dir="./Smarty/Config_File.class.php";//目录变量设置类
05	$smarty->caching=false;//不使用缓存
06	$smarty->template_dir="./templates";//设置模板目录
07	$smarty->complie_dir="./templates_c";//设置模板编译目录
08	$smarty->cache_dir="./smarty_cache";//缓存文件夹
09	$smarty->left_delimiter="{";
10	$smarty->right_delimiter="}";
11	?>
登录后复制

/templates/index.cpl 中代码如下:

01	<html>
02	<head>
03	<title>
04	{$kaishi}
05	</title>
06	</head>
07	<body>
08	<div>
09	<strong>hello,{$kaishi}</strong>
10	</div>
11	</body>
12	</html>
登录后复制

运行网页之后是一片空白

回复内容:

运行网页空白一片,不知道是不是哪里没有引用正确

所有的文件夹在同一个目录下面

我自己的项目包含目前如下几个文件夹

/Smarty

/smarty_cache 这个文件是我单独创建的

/templates 这个文件是我单独创建的

/templates_c 这个文件是我单独创建的

三个文件 /index.php /smarty.inc.php /templates/index.cpl

其中index.php中的内容如下:

1	<?php
2	 
3	include('smarty.inc.php');
4	$smarty->assign('kaishi','这个不知到怎么样,测试看看!');
5	$smarty->display('index.cpl');
6	 
7	?>
登录后复制

smarty.inc.php中的代码如下:

01	<?php
02	include_once("./Smarty/Smarty.class.php");//包含smarty类文件
03	$smarty=new Smarty();//建立Smarty实例对象$smarty
04	$smarty->config_dir="./Smarty/Config_File.class.php";//目录变量设置类
05	$smarty->caching=false;//不使用缓存
06	$smarty->template_dir="./templates";//设置模板目录
07	$smarty->complie_dir="./templates_c";//设置模板编译目录
08	$smarty->cache_dir="./smarty_cache";//缓存文件夹
09	$smarty->left_delimiter="{";
10	$smarty->right_delimiter="}";
11	?>
登录后复制

/templates/index.cpl 中代码如下:

01	<html>
02	<head>
03	<title>
04	{$kaishi}
05	</title>
06	</head>
07	<body>
08	<div>
09	<strong>hello,{$kaishi}</strong>
10	</div>
11	</body>
12	</html>
登录后复制

运行网页之后是一片空白

你所写的代码并没有问题,出问题的地方你可能忽略了。
1,如果你是在linux下做的测试,可能是你的php报错未开。
2,是在window下作的测试。根据你描述的,只能确定的就是模板没有被解析,(不然至少会出现‘hello,’)。

你的模板文件应该都没加载到。

相关标签:
php
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号