Stop print_r from printing 1's

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Stop print_r from printing 1's

Post by wmdvanzyl »

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?
zaidcrowe
Forum Members
Forum Members
Posts: 109
Joined: Wed Jun 10, 2009 3:43 pm

Re: Stop print_r from printing 1's

Post by zaidcrowe »

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
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Stop print_r from printing 1's

Post by velden »

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} -->
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Re: Stop print_r from printing 1's

Post by wmdvanzyl »

Thanks for the feedback.
zaidcrowe wrote:Have you tried {debug} or {get_template_vars} ...? Think both of these are documented in the tags section of the cms
I do use those, but there are times you just need to print_r something to the screen. :) 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 :D
velden wrote:<!-- {$var|print_r} -->
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. :)
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Stop print_r from printing 1's

Post by Jo Morg »

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!
zaidcrowe
Forum Members
Forum Members
Posts: 109
Joined: Wed Jun 10, 2009 3:43 pm

Re: Stop print_r from printing 1's

Post by zaidcrowe »

nice! i didnt know about this - some greeat discussion around this here: http://www.smarty.net/forums/viewtopic.php?p=16128
Post Reply

Return to “The Lounge”