[Fwd: Re: undefined vars in 'if' statements]

[email protected] (Dan Libby) Tue, 22 Feb 2000 10:56:50 -0800
Newsgroups php.template
Message-ID <[email protected]>
> > > >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