Re: [SMARTY] "if" with "or"-problem
| From: | Matthias Mohr | Date: | Thu, 03 Apr 2003 12:36:40 +0000 |
| Subject: | Re: [SMARTY] "if" with "or"-problem | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9056@lists.php.net to get a copy of this message | ||
>> {if $Flag1|default:0 eq 1 or $Flag2|default:1 eq 1}
> > Does the default-modifier don't work correct?
> > Or am I doing something wrong?
>
> it depends on what you would consider "correct".
>
> default uses the default value for the integer 0 (or the boolean
> false), but not for the string "0".
So if Flag2 is assigned to 0, the modifier default thinks, it is not
set and therefore it sets it to the string "1"?
> so if you do
> $smarty->assign( "Flag1", "0" );
> $smarty->assign( "Flag2", "0" );
>
> "false" is printed.
Yes, you're right :-)
> but be aware: if you do {assign var=Flag2 value=0}, $Flag2 is a string
> not an int. smarty treats all plugin-parameters as strings.
So it's a difference between assigning variables with PHP and assigning
through the assign-function inside smarty?
In PHP there is a difference between
$smarty->assign( "Flag1", 0 )
and
$smarty->assign( "Flag1", "0" )
?
And
{assign var="Flag1" value=0}
{assign var="Flag1" value="0"}
are the same (both assign a string)?
In my oppinion you should change the behaviour of the smarty-assign function,
so that it will do the same as the PHP version (or vice versa :-))
with regards,
Matthias