Re: [PHP] isset() VS if($var)

2001-04-09 Thread Jesper Blomström


This cleared up the difficulties!

I will look deep into the archive, now and forever.


Thanks from Stockholm, Sweden.


/ Jeppe

"PHPBeginner.com" wrote:
> 
> It is really a long discussion (check the archives of the last month - two)
> 
> Basically, isset() will tell you if the variable is declared, in other words
> it is set. It can still be empty but declared, and that will return you
> true;
> 
> if($var)
> 
> will return false only if
> 1. variable is not declared,
> 2. variable contains an empty string or 0.
> 
> the best (or at least my favorite) way to see if the variable contains
> anything is
> 
> if(isset($var) and $var!='')
> 
> this excludes every possibility of variable being empty or containing an
> empty string in it.
> 
> hope this helps.
> 
> Truly, check the archives, there so many things were said on this issue.
> 
> Sincerely,
> 
>  Maxim Maletsky
>  Founder, Chief Developer
> 
>  PHPBeginner.com (Where PHP Begins)
>  [EMAIL PROTECTED]
>  www.phpbeginner.com
> 
> -Original Message-
> From: Jesper Blomström [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 09, 2001 9:57 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] isset() VS if($var)
> 
> Hi!
> 
> Is there any difference between writing:
> 
> isset($my_var)
> 
> and...
> 
> if ($my_var)
> 
> ??
> 
> Thanks!
> 
> / Jesper Blomstroem
> 
> --
> Jesper Blomström
> [EMAIL PROTECTED]
> Arbete: 08-566 280 08
> Hem:08-669 23 10
> Mobil:  070-30 24 911
> 
> --
> 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]

-- 
Jesper Blomström
[EMAIL PROTECTED]
Arbete: 08-566 280 08
Hem:08-669 23 10
Mobil:  070-30 24 911

-- 
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] isset() VS if($var)

2001-04-09 Thread PHPBeginner.com

It is really a long discussion (check the archives of the last month - two)

Basically, isset() will tell you if the variable is declared, in other words
it is set. It can still be empty but declared, and that will return you
true;

if($var)

will return false only if
1. variable is not declared,
2. variable contains an empty string or 0.

the best (or at least my favorite) way to see if the variable contains
anything is

if(isset($var) and $var!='')

this excludes every possibility of variable being empty or containing an
empty string in it.

hope this helps.

Truly, check the archives, there so many things were said on this issue.


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com






-Original Message-
From: Jesper Blomström [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 09, 2001 9:57 PM
To: [EMAIL PROTECTED]
Subject: [PHP] isset() VS if($var)


Hi!

Is there any difference between writing:

isset($my_var)

and...

if ($my_var)


??


Thanks!



/ Jesper Blomstroem

--
Jesper Blomström
[EMAIL PROTECTED]
Arbete: 08-566 280 08
Hem:08-669 23 10
Mobil:  070-30 24 911

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




Re: [PHP] isset() VS if($var)

2001-04-09 Thread Adam Wright

isset actually sees if the variable exists, and has been assigned a value
(where if is obviously checking for boolean truthfulness). Thus...

$a = 0;

if (isSet($a))
  print "A is set"; //This line will execute

if (isSet($b))
  print "B is set"; //This line never will, as B has not been set to
anything every in this script

And...

if ($a)
  print "A is true"; //This line won't execute, A is false

if ($b)
  print "B is true"; //Because B has never been set, $b = 0, and this will
never execute

Hope that helps

adamw





- Original Message -
From: "Jesper Blomström" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 09, 2001 1:56 PM
Subject: [PHP] isset() VS if($var)


> Hi!
>
> Is there any difference between writing:
>
> isset($my_var)
>
> and...
>
> if ($my_var)
>
>
> ??
>
>
> Thanks!
>
>
>
> / Jesper Blomstroem
>
> --
> Jesper Blomström
> [EMAIL PROTECTED]
> Arbete: 08-566 280 08
> Hem:08-669 23 10
> Mobil:  070-30 24 911
>
> --
> 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]