A good approach to prevent this is to always put your constants on the
lefthand side of the condition. This causes a parser error if you accidently
try and assign instead of compare. It takes a bit of getting used to, but
once you get into the swing of it you'll find it a useful tool in your
arsenal of weapons against accidental bugs.
So, the previous example would read:
if ... "" == $myOra ... <--- This is correct
whereas:
if ... "" = $myOra ... <--- This would cause a parser error, you'd
see the mistake immediately
-----Original Message-----
From: Philip Olson [mailto:[EMAIL PROTECTED]]
Sent: 09 May 2001 10:23
To: Gabriele Biondo
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Little question
this :
if ... $myOra="" ...
should be more like :
if ... $myOra == "" ...
essentially you're setting $myOra as blank everytime which evaluates to
true, then it ends up printing the blank, which is not good. regarding
typos, this is a common one and since it reveals no error ... it can be
frustrating! :) you have others but this is the big one.
and for informational purposes :
http://php.net/manual/en/control-structures.php
http://php.net/manual/en/language.operators.comparison.php
regards,
philip
> > I have this little snippet of code:
> >
> >
> <?
> $myOra="MY STRING"
> >
> <?
> if (!(empty($myOra) || $myOra="")){
> ?>
> > <br>
> > <table width="550" border="0" align="center">
> > <tr bgcolor="ffffff">
> > <td colspan="3"><font
> > size="2""><b>Orario:</b><?print($myOra)?></font></td> </tr>
> > </table>
> >
> <?
> } endif
> ?>
> >
> > It should print a little table with the string "MY STRING"...
> > ... unfortunately, it doesn't.
> >
> > Any suggestion????
> >
> > BTW: I run this code on the following configuration:
> >
> > PHP Version: 4.0.4pl1
> > MySQL API version: 3.23.22-beta
> > Server API: httpd on a RHLinux 7.1
> >
> > Thanks in advance
> >
> > Gabriele Biondo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]