What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Determining Empty variables

Pages: (2): « First « 1 [ 2 ] Last »
Determining Empty variables
Author: Message:
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: RE: Determining Empty variables
quote:
Originally posted by John Anderton
quote:
Originally posted by matty
quote:
Originally posted by vikke
Mattike: == is the equal operator, not ===.
=== Is the bitwise-equal operator.
Also used to type specificity.
vikke, in php if you evaluate 0==false, the value would be true. Because its not testing the type of operands stored. doing 0===false would make it test the type as well which as matty correctly pointed out, is done by checking equality bitwise :-)
Oh I'm sorry, I don't know scripting too well, I'm used to C where == is the bitwise-equal operator. :)
4 8 15 16 23 42
04-29-2008 05:05 PM
Profile E-Mail PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: Determining Empty variables
quote:
Originally posted by Stigmata
I normally use (!$variable)?
Why are we talking about PHP in a JScript thread? :p

Anyway, these are equivalent with one major difference...

if(!$variable) { }

if(empty($variable)) { }


If $variable has not been set, the first will generate a warning message (which you'll only see if your error_reporting level includes E_NOTICE).

PHP Notice: Undefined variable: variable

So if you're sure a variable has been set, just use !$variable. If not, use empty().

Note: empty() is just a shorter way of doing this...

if(!isset($variable) || !$variable) { }
04-29-2008 05:46 PM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On