php smarty 访问显示空白,什么内容都没有?

WBOY
发布: 2016-06-06 20:41:51
原创
1409 人浏览过

访问127.0.0.1/smarty/test/test.php 一片空白 什么也没有
chrome 控制台报 server 500
但在chrome的隐身版本里没有这个错误
不知道什么原因,小白求助。。
test.php代码如下

<code><?php require("lib/Smarty.class.php"); //引入smarty 

    $smarty = new Smarty();  

    $smarty->left_delimiter ="{";//左定界符 

    $smarty->right_delimiter="}"; 

    $smarty->template_dir ="tpl";//视图模板存放地址 

    $smarty->compile_dir="template_c"; //模板编译后的存放目录 

    $smarty->cache_dir = "cache"; //缓存 

    $smarty->caching = true;  

    $smarty->cache_lifetime = 120; //缓存时间 

    $smarty->assign("title","标题"); //变量,value 

    $smarty->assign("content","内容"); 

    $smarty->display("test.html");  //模板名称 
 ?> 
</code>
登录后复制
登录后复制

放在tpl文件夹的 test.html

<code> 
     
        <title> {$title} </title> 
    
     
        {$content} 
     
 

</code>
登录后复制
登录后复制

使用的是ubuntut14.04。

回复内容:

访问127.0.0.1/smarty/test/test.php 一片空白 什么也没有
chrome 控制台报 server 500
但在chrome的隐身版本里没有这个错误
不知道什么原因,小白求助。。
test.php代码如下

<code><?php require("lib/Smarty.class.php"); //引入smarty 

    $smarty = new Smarty();  

    $smarty->left_delimiter ="{";//左定界符 

    $smarty->right_delimiter="}"; 

    $smarty->template_dir ="tpl";//视图模板存放地址 

    $smarty->compile_dir="template_c"; //模板编译后的存放目录 

    $smarty->cache_dir = "cache"; //缓存 

    $smarty->caching = true;  

    $smarty->cache_lifetime = 120; //缓存时间 

    $smarty->assign("title","标题"); //变量,value 

    $smarty->assign("content","内容"); 

    $smarty->display("test.html");  //模板名称 
 ?> 
</code>
登录后复制
登录后复制

放在tpl文件夹的 test.html

<code> 
     
        <title> {$title} </title> 
    
     
        {$content} 
     
 

</code>
登录后复制
登录后复制

使用的是ubuntut14.04。

<code>ini_set("display_errors","On"); error_reporting(E_ALL &~ E_NOTICE)
</code>
登录后复制

PHP配置文件默认设置不显示报错,可以直接设置php.ini文件

将display_errors = Off修改成

display_errors = On
即可。

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!