当前位置:Gxlcms > PHP教程 > ubuntu下Smarty3配置后页面空白解决方法

ubuntu下Smarty3配置后页面空白解决方法

时间:2021-07-01 10:21:17 帮助过:7人阅读

ubuntu下Smarty3 配置后 页面空白
今天学习了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


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



第一个 Smarty程序

















{$title}
{$author}
{$poem1} {$poem2}
{$poem3} {$poem4}




浏览器上输入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 还有很多不懂的东西,希望能得到解答。
------解决思路----------------------
打开错误提示呢?有错误么?

------解决思路----------------------
我指的是程序中ini_set("display_errors",1); error_reporting(E_ALL);的情况下,有没有报错。

这种smarty的空白页面,多半是目录的权限问题。不只是template_c,template, 父目录最起码也应该有x的权限,否则是无法写入的。

人气教程排行