Re:smarty_mod_default and number zero
| From: | Brian E. Lozier | Date: | Tue, 20 Nov 2001 09:28:51 +0000 |
| Subject: | Re:smarty_mod_default and number zero | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1985@lists.php.net to get a copy of this message | ||
While I'm not familiar with the function itself or what it's used for, in general I oppose
anything that
causes ambiguity or confusion. If 0 is considered empty in PHP, we should continue to use it as
such. Every
time we change something like this, it adds another 'gotcha' that everyone must remember.
Brian
========================
The Massassi Temple
http://www.massassi.net/
"How should I know if it works? That's what beta testers are for. I only coded it." -
Linus Torvalds
----- Original Message -----
From: Rene-Marc Simard <webmaster@sciflicks.com>
To: smarty@lists.ispi.net
Date: 11/20/01 1:24:05 AM
>
>Since the function 'empty()' sees the number zero [0] as being empty, and since
>people seem generally divided on the topic of whether such a behavior is really
>a bug or a feature (feelin' like paraphrasing Rich Kulawiec :), what would the
>Smarty community say if, for the add-on 'smarty_mod_default()', we tested
>against an empty string instead? The pseudo-diff function, currently using
>'empty()', would be:
>
>function smarty_mod_default($string, $default="")
>{
>- if(empty($string))
>+ if($string === '')
> return $default;
> else
> return $string;
>}
>
>This way, if a string really equals 0, the default would not kick in. Nothing
>earth shattering here, so I'm using my own default handler to circumvent the
>issue. But if the powers that be feel like it, perhaps it could be added to the
>snapshot?
>
>René-Marc Simard
>Popcorn Studios
>
>---
>You are currently subscribed to smarty as: brian@massassi.net
>To unsubscribe send a blank email to $subst('Email.Unsub')
>Visit Smarty's homepage at
>http://www.phpinsider.com/php/code/Smarty/