错误 Smarty - 致命错误:未捕获的异常

发布于 2024-11-13 12:23:15 字数 2074 浏览 1 评论 0原文

致命错误:未捕获异常“SmartyCompilerException”,第 9 行出现消息“模板“C:\xampp\htdocs\eventos\libs\templates\teste.tpl”中的语法错误“Ola! {$names}, bem vindo ao”聪明啊!” C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templatecompilerbase.php:441 中的未知标签“private_print_expression”' 堆栈跟踪:#0 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templatecompilerbase.php(263): Smarty_Internal_TemplateCompilerBase->trigger_template_error('未知标签 "pr...', 9) #1 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templateparser.php(2338): Smarty_Internal_TemplateCompilerBase->compileTag('private_print_e.. .',数组,数组) #2 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templateparser.php(2846): Smarty_Internal_Templateparser->yy_r28() #3 C:\xampp\htdocs\eventos\libs\sysplugins \smarty_internal_templateparser.php(2946): Smarty_Internal_Templateparser->yy_reduce(30) #4 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_smartytemplatecompiler.php(51): 智能在 C:\xampp\htdocs\eventos\libs \sysplugins\smarty_internal_templatecompilerbase.php 第 441 行

我的 php 代码

<?php
include('includes/header.html');
include('conf/conf.php');
require_once(SMARTY_DIR.'Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = 'C:\xampp\htdocs\eventos\libs\templates';
$smarty->compile_dir = 'C:\xampp\htdocs\eventos\libs\templates_c';
$smarty->config_dir = 'C:\xampp\htdocs\eventos\libs\configs';
$smarty->cache_dir = 'C:\xampp\htdocs\eventos\libs\cache';

$smarty->assign('name','Ned');

$smarty->display('teste.tpl');
?>

和我的智能代码 (teste.tpl)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Ola! {$name}, bem vindo ao Smarty!
</body>
</html>

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "C:\xampp\htdocs\eventos\libs\templates\teste.tpl" on line 9 "Ola! {$names}, bem vindo ao Smarty!" unknown tag "private_print_expression"' in C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templatecompilerbase.php:441 Stack trace: #0 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templatecompilerbase.php(263): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown tag "pr...', 9) #1 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templateparser.php(2338): Smarty_Internal_TemplateCompilerBase->compileTag('private_print_e...', Array, Array) #2 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templateparser.php(2846): Smarty_Internal_Templateparser->yy_r28() #3 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templateparser.php(2946): Smarty_Internal_Templateparser->yy_reduce(30) #4 C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_smartytemplatecompiler.php(51): Smart in C:\xampp\htdocs\eventos\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 441

my php code

<?php
include('includes/header.html');
include('conf/conf.php');
require_once(SMARTY_DIR.'Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = 'C:\xampp\htdocs\eventos\libs\templates';
$smarty->compile_dir = 'C:\xampp\htdocs\eventos\libs\templates_c';
$smarty->config_dir = 'C:\xampp\htdocs\eventos\libs\configs';
$smarty->cache_dir = 'C:\xampp\htdocs\eventos\libs\cache';

$smarty->assign('name','Ned');

$smarty->display('teste.tpl');
?>

and my smart code (teste.tpl)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Ola! {$name}, bem vindo ao Smarty!
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

向日葵 2024-11-20 12:23:15

更改

$smarty->assign('name','Ned');

$smarty->assign('names','Ned');

change

$smarty->assign('name','Ned');

to

$smarty->assign('names','Ned');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文