How to Debug Variables in Smarty like in PHP var_dump()

后端 未结 13 523
别那么骄傲
别那么骄傲 2020-12-22 16:13

I have some variables inside a template and I don\'t know where I assigned them. I need to know what is inside a particular variable; for instance, say I have a variable in

相关标签:
13条回答
  • 2020-12-22 16:33

    To debug in smarty in prestashop 1.6.x :

    {ffffd($variable)} -> debug and die
    
    {ppp($variable)} -> debug only
    

    An onther usefull debug tag :

    {debug}
    
    0 讨论(0)
  • 2020-12-22 16:34

    In smarty there is built in modifier you could use that by using | (single pipeline operator). Like this {$varname|@print_r} will print value as print_r($php_variable)

    0 讨论(0)
  • 2020-12-22 16:35

    For what it's worth, you can do {$varname|@debug_print_var} to get a var_dump()-esque output for your variable.

    0 讨论(0)
  • 2020-12-22 16:36

    {$variable|@debug_print_var nofilter} and you not need to add "<pre>" tags

    {$variable|var_dump} show you more (but worse formatting) because debug_print_var not showing private variable in object!

    0 讨论(0)
  • 2020-12-22 16:39

    Try out with the Smarty Session:

    {$smarty.session|@debug_print_var}
    

    or

    {$smarty.session|@print_r}
    

    To beautify your output, use it between <pre> </pre> tags

    0 讨论(0)
  • 2020-12-22 16:45

    in smarty V3 you can use this

    {var_dump($variable)}

    0 讨论(0)
提交回复
热议问题