展会信息港展会大全

Warning: Smarty error: unable to read resource
来源:互联网   发布日期:2016-01-14 11:16:08   浏览:2399次  

导读: 今天第一次写smarty就出来这样的提示:Warning: Smarty error: unable to read resource,代码如下<?phpinclude_once("...

今天第一次写smarty就出来这样的提示:Warning: Smarty error: unable to read resource,代码如下

<?php

include_once("Smarty/libs/Smarty.class.php");

$smarty =new Smarty();

$smarty->template_dir ='Smarty/template';

$smarty->compile_dir ='Smarty/template_c';

$smarty->left_delimiter ='<{';

$smarty->right_delimiter='}>';

$smarty->assign('first','第一个');

$smarty->display('one.tpl');

?>

one.tpl文件如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

</head>

<body>

<{include file="head.tpl"}>

this is my the <{$first}> smarty!

<{include file="bot.tpl"}>

</body>

</html>

head.tpl和bot.tpl文件是头部和尾部文件,这个有一点像asp里面的include的调用外部文件的方式,

看上去代码很简单但怎么会出来这种问题呢?仔细查看后发原来是one.tpl 文件没有放到template目录下,为什么一定要放在这个目录下呢?好我们来看上面的一代码, $smarty->template_dir ='Smarty/template';仔细一看才明白 template是设计模板文件所在的目录,因为我one.tpl文件放在根目录所以就会出现这种问题.

我想大家应该也知道问题出现在哪里了吧

赞助本站

人工智能实验室

相关热词: php 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港