I was wondering whether there is a way to stop the print_r function from printing 1's all over the place. I assume it is the "true" value it returns after completing successfully. I was wondering if there is a way around this or perhaps there is a better way to debug stuff when you need screen output than print_r?
Any suggestions?
Stop print_r from printing 1's
Re: Stop print_r from printing 1's
Re the '1' this can happen for a coupla reasons, say a function returning true, or if you do it against an array (i think) it can mean that the array is set, but has no values
Have you tried {debug} or {get_template_vars} ...? Think both of these are documented in the tags section of the cms
Have you tried {debug} or {get_template_vars} ...? Think both of these are documented in the tags section of the cms
Re: Stop print_r from printing 1's
Or use it in html comment, so your visitors don't see it while you're debugging (unless they look in source).
End you don't need the <pre> tags
<!-- {$var|print_r} -->
End you don't need the <pre> tags
<!-- {$var|print_r} -->
Re: Stop print_r from printing 1's
Thanks for the feedback.
Where i got confused was when the output of print_r was actually 1, but i couldn't see it amongst all the 'other' 1's 

I do use those, but there are times you just need to print_r something to the screen.zaidcrowe wrote:Have you tried {debug} or {get_template_vars} ...? Think both of these are documented in the tags section of the cms


That's smart, but in this case it wasn't the output to end users that needed to be altered, but rather the output i get. If, for example, i output a variable which has a value of 1, i tend to miss it and think that it is blank, because there are so many 1's floating around.velden wrote:<!-- {$var|print_r} -->

Re: Stop print_r from printing 1's
Try:
Code: Select all
{$var|print_r:true}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: Stop print_r from printing 1's
nice! i didnt know about this - some greeat discussion around this here: http://www.smarty.net/forums/viewtopic.php?p=16128