>  기사  >  백엔드 개발  >  php smarty 访问显示空白,什么内容都没有?

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

WBOY
WBOY원래의
2016-06-06 20:41:511405검색

访问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
即可。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.