variable was used before it was defined

I always get this message from Zend Editor saying : "This variable was used before it was defined" with an orange curvy line below it. what does this exactly mean and how do I define a variable before I use it?

best regards,
Who is Participating?
Ara-Connect With a Mentor Commented:
OK. Know I understand why you get that message. You should use the isset function:

I don't know this Zend Editor, but many programming languages require / recommend that you declare a variable before using it. That means that you specify what kind of value the variable can hold (and of which size) before you assign a value to it. In PHP however the variable is declares as it first appears and is assigned a value. I guess this is a warning in Zend Editor and that it doesn't have any effect really. The script works?
ShopiesAuthor Commented:
Well let me clarify something here. I'm building a login system and all the control panel files must check if the bariable $user_name is assigned or not. If yes, then the admin could use the control and if not it will prompt him back to login form or it should be. When I tried to add "index.php?act=idx&user_name=pah" in the address bar it logged me in without prompting me to the login form although I didn't login. Here is a Snippet of my .php header files which is located in the very top of my .php files
		if(!$user_name) {
			$log = new TemplatePower("temps/login.htm");
			$log -> prepare();
			$log -> printToScreen();

Open in new window

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

ShopiesAuthor Commented:
I really don't know how to define the variable "$user_name" other than this way.
I would also use post instead of get when dealing with a login-system. Would need some more information about how it is supposed to work etc. if I was to help you more.
ShopiesAuthor Commented:
Thank you so much. exactly, the thing that I missed was the function isset and when I used it the problem has been resolved.

Many thanks buddy ;)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.