[請益] smarty 出錯
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
推
02/21 23:05, , 1F
02/21 23:05, 1F
→
02/21 23:06, , 2F
02/21 23:06, 2F
推
02/21 23:10, , 3F
02/21 23:10, 3F
謝謝~我拿掉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)
推
02/22 11:13, , 4F
02/22 11:13, 4F
事實上我也試過了
囧
※ 編輯: pttnews 來自: 59.120.175.188 (02/22 11:25)
→
02/22 11:52, , 5F
02/22 11:52, 5F
測過了~
感謝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)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章