"variable does not seem to be used in its scope" - IDE Warning

Hello all,

I’m getting warnings on my IDE on some vars, telling:

“variable does not seem to be used in its scope”.

Is there a best practice about using the variables on their scope?

Here is a sniped example:

//com, net TLD
  $intnomatch="No match for";

      //int settings

Is it because we are declaring those outside the if?
What if we have to use them inside and outside the if?

Assuming that this is not a best practice, where can we learn more about this?


It looks like perfectly valid code to me Marcio, it sounds like sloppy code intelligence from your IDE.

Ok. I will disable that warning feature and inform the Netbeans developers community about it.

Maybe it’s a java thing that we must declare a scope on our vars but that isn’t the case in php. I don’t know, just guessing.

Anyway, thanks (again) :-),

The only thing I can think of is if you are using the vars assigned within the IF conditional later on in your code, it maybe warning you that those vars maybe never be set.

It’s a experimental feature that I decided to enable. Because I’m newbie on all this and I said: I want all the warnings to be throughout so that I can assure that I’m coding correct not only on the sintax but also building a “well formed code”. (if we called like this).
Mea Culpa here.

However, I have created a new file only with the code above and the warning is still there, hence, I do believe it’s a feature that needs to be clean on the IDE side as you firstly suggested.

I will inform and disable this option for now.



In my Netbeans install (6.8) this warning is categorized as “Experimental” and disabled by default. They’ve probably not had time to finish implementing it yet.