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

Determining Empty variables
Author: Message:
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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Determining Empty variables - by le-foot on 04-28-2008 at 10:36 AM
RE: Determining Empty variables - by Skarbo on 04-28-2008 at 10:41 AM
RE: Determining Empty variables - by matty on 04-28-2008 at 01:20 PM
RE: Determining Empty variables - by Matti on 04-28-2008 at 04:14 PM
RE: Determining Empty variables - by vikke on 04-28-2008 at 04:41 PM
RE: Determining Empty variables - by matty on 04-28-2008 at 05:55 PM
RE: Determining Empty variables - by John Anderton on 04-28-2008 at 06:00 PM
RE: RE: Determining Empty variables - by vikke on 04-29-2008 at 05:05 PM
RE: Determining Empty variables - by MeEtc on 04-28-2008 at 10:10 PM
RE: Determining Empty variables - by Stigmata on 04-28-2008 at 10:49 PM
RE: Determining Empty variables - by Matti on 04-29-2008 at 04:30 PM
RE: Determining Empty variables - by WDZ on 04-29-2008 at 05:46 PM


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