RE: [PHP] Re: ramble was [PHP] Not sure of my error
| From: | Mark Maggelet | Date: | Sat, 18 Nov 2000 03:27:51 +0000 |
| Subject: | RE: [PHP] Re: ramble was [PHP] Not sure of my error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26017@lists.php.net to get a copy of this message | ||
On Fri, 17 Nov 2000 17:45:46 -0800 (PST), jeremy brand
(jeremy@nirvani.net) wrote:
>> > In my opinion, if you don't want to have errors on undeclared
>> > variables, then the only way to be sure you are not going to get
>> > errors is to declare them!
>>
>> What about just checking with
>>
>> if (isset($foo)) {
>> if (!$foo)
>> echo "nothing here";
>> }
>
>I believe that it just depends on your application. I try and code
>so
>that I _DO_ know what is set and what is not.
>
>When I am up against odds and I need to do something like this, here
>is what I do (sometimes) and here is my reasoning.
>
>I use strlen()
This is silly. Even if it works the way you want it to, it's bad
style. If I joined your project late and had to look at it I would
not understand what you're trying to do.
There's no reason for it, that's the reason isset() exists.
if you want to check to see if a var is set, use:
if(isset($var))
if you want to see if a var is set and non-zero, use
if((isset($var))&&($var!=0))
- Mark