Re: Handling TRUE,FALSE,NULL,ON,OFF, etc
"Mark Rogers" <[email protected]>
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Organization | Quarella Ltd |
| Message-ID | <036701c41c74$d2bad460$1100000a@mark> |
messju mohr writes:
> Tagnames, modifiers and variable-names are all case-sensitive. I see
> nothing wrong with "true", "null" etc. also being case-sensitive and
> only accepted in lowercase.
PHP would disagree with you, in as much as TRUE/FALSE/NULL are valid in PHP,
even though $x and $X are different. (I know we're talking about Smarty
syntax, though, not PHP.)
Interestingly,
var_dump(null,true,false);
gives
NULL bool(true) bool(false)
so we should at least expect true/false/NULL not true/false/null in Smarty?
Regarding modifiers,
{"xx"|STRTOUPPER} works (ie using a PHP function)
whereas
{""|DEFAULT:"YY"} doesn't.
However, the behaviour when I try {""|DEFAULT:"YY"} (Smarty error) is very
different from when I try TRUE (no complaint, treated as "TRUE") vs true
(seen as bool(true)).
Given all of this, is there really a good reason _not_ to accept
TRUE/FALSE/NULL/ON/OFF etc? The performance impact is negligible (and only
to the compiler).
I think this is where I disagree with you - if Smarty did only accept
"true", "false" etc in lowercase I would see your point. The problem is it
*does* accept them, but treats them non-intuitively. Either it should error
on them as ambiguous (which would be a lot of coding for little benefit) or
should at least handle them the way the user would expect.
--
Mark Rogers,
More Solutions Ltd :: Tel: 0845 45 89 555
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php