[FX.php List] 1 success, one failure
Joel Shapiro
jsfmp at earthlink.net
Thu Feb 7 11:31:37 MST 2008
Just a word of caution for anyone adapting someone else's code...
using
if (isset($myvar))
might not give you the results you expect because if $myvar is
anywhere declared as
$myvar = ''; // empty quotes
then
if (isset($myvar))
would evaluate to true, even though you might expect it to be false.
if (isset($myvar) && $myvar != '')
is probably a safer test.
If it's all your own code though, you'll probably know whether
there's any chance that $myvar might ever be set to '', so using [if
(isset($myvar))] might be sufficient.
-Joel
On Feb 7, 2008, at 7:58 AM, Dale Bengston wrote:
> I changed my logic from ...
>
> if ($myvar)
>
> ... to ....
>
> if (isset($myvar))
>
> Dale
>
> On Feb 7, 2008, at 9:53 AM, Bob Patin wrote:
>
>> this may be a stupid question, but is declaring variables as
>> simple as just saying
>>
>> $myvar = 0;
>>
>> ?
>>
>> Or is there a more-accepted method of doing that, like one does
>> for declaring an array?
>>
>> BP
>>
>>
>> On Feb 7, 2008, at 9:50 AM, Dale Bengston wrote:
>>
>>> Yes, undeclared variables got me too. That and short tages and
>>> some old, old references to $_HTTP_SERVER_VARS that should have
>>> been $_SERVER. The short tags and the $_HTTP_SERVER_VARS were
>>> easy to repair with global search-and-replace. The undeclared
>>> variables had to be done by hand.
>>>
>>> Dale
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list