Re: Sloppy coding?
| From: | Shawn McKenzie | Date: | Wed, 07 May 2003 04:32:40 +0000 |
| Subject: | Re: Sloppy coding? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146621@lists.php.net to get a copy of this message | ||
Sorry... too much wine! I get it.
So if(!isset($someval)) will execute if $someval = null or ""?
-Shawn
"Shawn McKenzie" <nospam@mckenzies.net> wrote in message
news:20030507042931.3165.qmail@pb1.pair.com...
> That would clear it up, except that I use the first if() all of time and
it
> doesn't execute if I haven't defined the var, such as a script that
receives
> post or get and that var was not included in the post or get.
>
> Thanks!
> Shawn
>
> "Martin Towell" <martin.towell@world.net> wrote in message
>
> news:6416776FCC55D511BC4E0090274EFEF508207078@exchange.world.net...
> > Supposing $somevar has one of the following values: unset, null, 0, "",
> > false
> > the first if() will execute
> > while the second will only execute for "unset"
> >
> > hope that clears things up....
> >
> > -----Original Message-----
> > From: Shawn McKenzie [mailto:nospam@mckenzies.net]
> > Sent: Wednesday, May 07, 2003 2:21 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Sloppy coding?
> >
> >
> > I want to sidestep any pitfalls and try to be a good coder. So what is
> the
> > difference between these two:
> >
> > if(!$somevar){
> > ...do stuff
> > }
> >
> > if(!isset($somevar)){
> > ...do stuff
> > }
> >
> > If one is bad, then are there any other common pitfalls similar to this
> that
> > I should avoid???
> >
> > Thanks!
> > Shawn
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>