EnzoLiu
2016-12-27 21:38
实际上在smarty中不需要使用print_r函数,但smarty中支持php的内置函数 按理说也是可以正常使用的,于是...测试了下
<?php
require './libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->setTemplateDir('tpl');
$smarty->setCompileDir('template_c');
$smarty->setCacheDir('cache');
$smarty->caching = false;
$smarty->cache_lifetime = 120;
$smarty->display('test.tpl');
?>test.tpl中的代码:
{"a"|print_r}打印结果是 a1
为何?不应该是a吗?
纳闷之余,去翻看了一下smarty编译后的php程序发现了如下代码:
function content_58626d30228a24_11924857 (Smarty_Internal_Template $_smarty_tpl) {
echo print_r("a");
}原来是prinr_r打印后返回了一个true,后面的echo又跟上来打印true,php自动将true转变成了1给打印了。。
...
解决了
MVC架构模式分析与设计
82447 学习 · 954 问题
相似问题