ubuntu下Smarty3 配置后 页面空白

j335150925 2015-02-04 08:19:32
今天学习了php 的smarty模板,在机器搭建的时候 ,按照教程下载了Smarty-3.1.21.tar.gz 解压后将lib文件放至/var/www/html/SM 并改变文件夹名为smarty 并在/var/www/html/SM 目录下创建templates templates_c两个文件夹 并修改权限至 drwxrwxrwx

在/var/www/html/SM 目录下新建php文件 index.php
<?php


require './smarty/Smarty.class.php' ;
$smarty=new Smarty();
$smarty->setTemplateDir('./templates');
$smarty->setCompileDir('./templates_c');
//print_r($smarty->setCompileDir());
$smarty->assign('title',"dfdf");
$smarty->assign('author',"dfdf");
$smarty->assign('poem1',"dfdf");
$smarty->assign('poem2',"dfdf");
$smarty->assign('poem3',"dfdf");
$smarty->assign('poem4',"dfdf");
$smarty->display('Example1801.html');
?>

在/var/www/html/SM/templates 目录下新建html文件 Example1801.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>第一个 Smarty程序</title>
</head>
<body>
<table border="1">
<tr>
<td colspan="2" align="center">{$title}</td>
</tr>
<tr>
<td colspan="2">{$author}</td>
</tr>
<tr>
<td width="120">{$poem1}</td>
<td width="120">{$poem2}</td>
</tr>
<tr>
<td>{$poem3}</td>
<td>{$poem4}</td>
</tr>
</table>
</body>
</html>


浏览器上输入http://localhost/SM/index.php后显示空白页
运行print_r($smarty->setCompileDir());
显示
Smarty Object ( [auto_literal] => 1 [error_unassigned] => [use_include_path] => [template_dir:Smarty:private] => Array ( [0] => ./templates/ ) [joined_template_dir] => ./templates/ [joined_config_dir] => ./configs/ [default_template_handler_func] => [default_config_handler_func] => [default_plugin_handler_func] => [compile_dir:Smarty:private] => / [plugins_dir:Smarty:private] => Array ( [0] => /var/www/html/SM/smarty/plugins/ ) [cache_dir:Smarty:private] => ./cache/ [config_dir:Smarty:private] => Array ( [0] => ./configs/ ) [force_compile] => [compile_check] => 1 [use_sub_dirs] => [allow_ambiguous_resources] => [caching] => [merge_compiled_includes] => [inheritance_merge_compiled_includes] => 1 [cache_lifetime] => 3600 [force_cache] => [cache_id] => [compile_id] => [left_delimiter] => { [right_delimiter] => } [security_class] => Smarty_Security [security_policy] => [php_handling] => 0 [allow_php_templates] => [direct_access_security] => 1 [debugging] => [debugging_ctrl] => NONE [smarty_debug_id] => SMARTY_DEBUG [debug_tpl] => file:/var/www/html/SM/smarty/debug.tpl [error_reporting] => [get_used_tags] => [config_overwrite] => 1 [config_booleanize] => 1 [config_read_hidden] => [compile_locking] => 1 [cache_locking] => [locking_timeout] => 10 [template_functions] => Array ( ) [default_resource_type] => file [caching_type] => file [properties] => Array ( ) [default_config_type] => file [template_objects] => Array ( ) [cache_modified_check] => [registered_plugins] => Array ( ) [plugin_search_order] => Array ( [0] => function [1] => block [2] => compiler [3] => class ) [registered_objects] => Array ( ) [registered_classes] => Array ( ) [registered_filters] => Array ( ) [registered_resources] => Array ( ) [_resource_handlers] => Array ( ) [registered_cache_resources] => Array ( ) [_cacheresource_handlers] => Array ( ) [autoload_filters] => Array ( ) [default_modifiers] => Array ( ) [escape_html] => [start_time] => 1423049920.1225 [_file_perms] => 420 [_dir_perms] => 505 [_tag_stack] => Array ( ) [smarty] => Smarty Object *RECURSION* [_current_file] => [_parserdebug] => [merged_templates_func] => Array ( ) [template_class] => Smarty_Internal_Template [tpl_vars] => Array ( ) [parent] => [config_vars] => Array ( ) )

网上很多网友说是权限的问题,导致不能对templates_c进行写,我已经用chmod 777 更改权限,但是问题还是不能解决,希望有大神出来解答一下,刚刚使用ubuntu和接触php 还有很多不懂的东西,希望能得到解答。
...全文
328 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
j335150925 2015-02-05
  • 打赏
  • 举报
回复
引用 4 楼 ohmygirl 的回复:
我指的是程序中ini_set("display_errors",1); error_reporting(E_ALL);的情况下,有没有报错。 这种smarty的空白页面,多半是目录的权限问题。不只是template_c,template, 父目录最起码也应该有x的权限,否则是无法写入的。
加了这两句之后还是没有报错 依然空白页面 父目录也修改了权限 但问题还是没有解决.....
ohmygirl 2015-02-04
  • 打赏
  • 举报
回复
我指的是程序中ini_set("display_errors",1); error_reporting(E_ALL);的情况下,有没有报错。 这种smarty的空白页面,多半是目录的权限问题。不只是template_c,template, 父目录最起码也应该有x的权限,否则是无法写入的。
j335150925 2015-02-04
  • 打赏
  • 举报
回复
引用 1 楼 ohmygirl 的回复:
打开错误提示呢?有错误么?
我是用PHPSTORM的 打开页面为空白 没有警告报错什么的....
j335150925 2015-02-04
  • 打赏
  • 举报
回复
我是用PHPSTORM的 打开页面为空白 没有警告报错什么的....
ohmygirl 2015-02-04
  • 打赏
  • 举报
回复
打开错误提示呢?有错误么?

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧