[Fwd: Re: undefined vars in 'if' statements]
| From: | Dan Libby | Date: | Tue, 22 Feb 2000 18:56:50 +0000 |
| Subject: | [Fwd: Re: undefined vars in 'if' statements] | ||
| Groups: | php.template | ||
| Request: | Send a blank email to php-template+get-201@lists.php.net to get a copy of this message | ||
> > > >Perhaps the question you are asking is whether the if statement should
> > > >behave like a section with regard to autohide, and I think the answer is
> > > >yes. It seems like autohide could/should be an attribute of any block
> > > >type.
> > >
> > > You mean, just skip the 'if' statement if it's comparing a variable
> > > that's
> > > not defined? I'm not sure it's such a good idea...
> >
> > No, I was referring to what would/should happen if a variable is referenced
> > within the if section that was not defined. In that case, I think the if
> > statement should have the same behavior as a regular section.
>
> What do you mean by that?
For example:
{{:if $fname=="dan"}}
First: {{fname}}<BR>
Last: {{lname}}
{{/:if}}
In this case, if lname is undefined, it would be blank, however in the
next
example the entire if statement would be hidden.
{{:if $fname=="dan" autohide="yes"}}
First: {{fname}}<BR>
Last: {{lname}}
{{/:if}}
The alternative is:
{{:section foobar autohide="yes"}}
{{:if $fname=="dan"}}
First: {{fname}}<BR>
Last: {{lname}}
{{/:if}}
{{/:section foobar}}
> > The if statement should in fact allow testing for whether a variable is
> > defined or not.
>
> Is {{ if $name }} enough?
Seems reasonable. We need to define the difference between undefined
and an empty
string though.
-dan