Re: [PHP] if(isset($a)) vs if($a)

2001-09-16 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Mark) wrote:

 if(isset($) and !empty($a) and !$a)
 
 this is the same as if(!empty($a))
 
 or
 
 if(isset($) and $a===FALSE)
 
 this is the same as if(empty($a))

(Aside from accidentally omitted the a in the var name...oops...) 

No, they're not the same thing if you have error reporting set to E_ALL.  
If $a is not set, calling empty($a) or !$a produces a warning.

-- 
CC

-- 
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]




Re: [PHP] if(isset($a)) vs if($a)

2001-09-16 Thread Mark

On Sun, 16 Sep 2001 09:18:23 -0700, CC Zona wrote:
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Mark) wrote:

 if(isset($) and !empty($a) and !$a)

 this is the same as if(!empty($a))

 or
 
 if(isset($) and $a===FALSE)

 this is the same as if(empty($a))

Aside from accidentally omitted the a in the var name...oops...)

No, they're not the same thing if you have error reporting set to
E_ALL.
If $a is not set, calling empty($a) or !$a produces a warning.

calling empty($a) does not give a warning.

--
Mark, [EMAIL PROTECTED] on 09/16/2001



--
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]




Re: [PHP] if(isset($a)) vs if($a)

2001-09-16 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Mark) wrote:

 calling empty($a) does not give a warning.

Sheesh.  It doesn't at that.  WTF?

-- 
CC

-- 
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]




Re: [PHP] if(isset($a)) vs if($a)

2001-09-15 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Andrew Perevodchik) wrote:

 JD isset checks to see if the $a variable has
 JD been set, ie, if it exists. if($a) checks for
 JD the truthood of $a, meaning, if it has a
 JD non-zero, non-null/empty-string value, then
 JD its true, else, false.
 
 ... and if it's not set at all it returns a
 warning unless you use @ :(

Or change the error_reporting level, or turn off display_errors (okay, 
technically the warning is still happening in the latter case, but IIRC 
that's also true of @--both simply suppress the *reporting* of the report 
rather than the *occurance* of the error).

This is why it's best to do multiple checks and choose them carefully.  Ex:

if(isset($) and !empty($a) and !$a)

or

if(isset($) and $a===FALSE)

etc.

-- 
CC

-- 
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]




Re: [PHP] if(isset($a)) vs if($a)

2001-09-15 Thread Mark

On Sat, 15 Sep 2001 13:20:59 -0700, CC Zona wrote:
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Andrew Perevodchik) wrote:

 JD isset checks to see if the $a variable has
 JD been set, ie, if it exists. if($a) checks for
 JD the truthood of $a, meaning, if it has a
 JD non-zero, non-null/empty-string value, then
 JD its true, else, false.

 ... and if it's not set at all it returns a
 warning unless you use @ :(

Or change the error_reporting level, or turn off display_errors
(okay,
technically the warning is still happening in the latter case, but
IIRC
that's also true of @--both simply suppress the *reporting* of the
report
rather than the *occurance* of the error).

This is why it's best to do multiple checks and choose them
carefully.  Ex:

if(isset($) and !empty($a) and !$a)

this is the same as if(!empty($a))

or

if(isset($) and $a===FALSE)

this is the same as if(empty($a))


--
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]




RE: [PHP] if(isset($a)) vs if($a)

2001-09-14 Thread Jack Dempsey

isset checks to see if the $a variable has been set, ie, if it exists.
if($a) checks for the truthood of $a, meaning, if it has a non-zero,
non-null/empty-string value, then its true, else, false.

jack

-Original Message-
From: David Yee [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 14, 2001 6:04 PM
To: [EMAIL PROTECTED]
Subject: [PHP] if(isset($a)) vs if($a)


Hi.  What is the difference between:

if(isset($a))

and

if($a)

???  Thanks.

David


-- 
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]