[請益] smarty 出錯

看板PHP作者 (PTT新聞)時間12年前 (2013/02/21 21:35), 編輯推噓3(302)
留言5則, 2人參與, 最新討論串1/1
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
看一下templates_c資料夾中compile出來的那個php 第27行
02/21 23:05, 1F

02/21 23:06, , 2F
可能是smarty產生出來的code跟你系統衝突了 (亂猜)
02/21 23:06, 2F

02/21 23:10, , 3F
另,你php檔第9行參數錯誤喔 @@ assign() 裡面要有值
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
試試看 chmod 777 吧
02/22 11:13, 4F
事實上我也試過了 囧 ※ 編輯: pttnews 來自: 59.120.175.188 (02/22 11:25)

02/22 11:52, , 5F
結案 775 !
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)
文章代碼(AID): #1H9YAcL1 (PHP)
文章代碼(AID): #1H9YAcL1 (PHP)