作者pttnews (PTT新闻)
看板PHP
标题[请益] smarty 出错
时间Thu Feb 21 21:35:29 2013
error.log 出现error Exception
我用lighttpd + PHP Version 5.2.17 + Smarty3
可以请教出错原因吗?
谢谢~
2013-02-21 21:24:59: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Warning:
Missing argument 1 for Smarty_Internal_Data::assign(),
called in /opt/share/www/blog/main.php on line 9 and
defined in /opt/share/www/blog/class/sysplugins/smarty_internal_data.php
on line 54
PHP Notice: Undefined variable: tpl_var in
/opt/share/www/blog/class/sysplugins/smarty_internal_data.php on line 56
PHP Notice: Undefined variable: tpl_var in
/opt/share/www/blog/class/sysplugins/smarty_internal_data.php on line 63
2013-02-21 21:24:59: (mod_fastcgi.c.2676)
FastCGI-stderr: PHP Parse error:
syntax error, unexpected '+', expecting
'(' in /opt/share/www/blog/templates_c/
7966dad18dd5cbf791b92e516a57aeb13be2cbb0.file.test.htm.php on line 27
test.php
<?php
include "class/Smarty.class.php";
define('__SITE_ROOT', '/opt/share/www/blog'); // 最後没有斜线
$tpl = new Smarty();
$tpl->template_dir = __SITE_ROOT . "/templates/";
$tpl->compile_dir = __SITE_ROOT . "/templates_c/";
$tpl->config_dir = __SITE_ROOT . "/configs/";
$tpl->cache_dir = __SITE_ROOT . "/cache/";
$tpl->assign();
$tpl->left_delimiter = '<{';
$tpl->right_delimiter = '}>';
$tpl->assign("title", "测试用的网页标题");
$tpl->assign("content", "测试用的网页内容");
$tpl->display('test.htm');
?>
test.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title><{$title}></title>
</head>
<body>
<{$content}>
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.143.146
1F:推 water2924:看一下templates_c资料夹中compile出来的那个php 第27行 02/21 23:05
2F:→ water2924:可能是smarty产生出来的code跟你系统冲突了 (乱猜) 02/21 23:06
3F:推 water2924:另,你php档第9行参数错误喔 @@ assign() 里面要有值 02/21 23:10
谢谢~我拿掉assign()
但是还是error
我附上完整讯息
2013-02-22 11:03:27: (mod_fastcgi.c.2676)
FastCGI-stderr: PHP Fatal error: Uncaught exception
'SmartyException' with message 'unable to write file
/opt/share/www/blog/templates_c/wrt5126dffff0a212.1/-42+3,'
in /opt/share/www/blog/class/sysplugins/smarty_internal_write_file.php:44
很困惑的是我按照官网步骤
chown nobody:nobody /opt/share/www/blog/templates_c/
chmod 770 /opt/share/www/blog/templates_c/
chown nobody:nobody /opt/share/www/blog/cache/
chmod 770 /opt/share/www/blog/cache/
也用testInstall() 来测试Smarty是否有权限读写这些目录。
还是不懂哪里出错?
※ 编辑: pttnews 来自: 59.120.175.188 (02/22 11:09)
4F:推 water2924:试试看 chmod 777 吧 02/22 11:13
事实上我也试过了
囧
※ 编辑: pttnews 来自: 59.120.175.188 (02/22 11:25)
5F:→ twsphere:结案 775 ! 02/22 11:52
测过了~
感谢twsphere 、 water2924 大德~
我在此留下纪录,供人参考
软体环境 PHP Version 5.2.17 + SMARTY 3.1.13
硬体 asus rt-16n
OS Tomato linux
Smarty 经测试出现
Uncaught exception 'SmartyException' with message 'unable to write file
当初官网说
chown nobody:nobody /opt/share/www/blog/templates_c/
chmod 770 /opt/share/www/blog/templates_c/
chown nobody:nobody /opt/share/www/blog/cache/
chmod 770 /opt/share/www/blog/cache/
就算用testInstall() 来测试Smarty是否有权限读写这些目录,事实上也不准确
要改为chmod 775 才可以
PS: 我一刚开始 chmod 777, 试过不行,现在回想,也许是没搭配chown nobody:nobody
※ 编辑: pttnews 来自: 59.120.175.188 (02/22 12:05)