Checking if a variable has been set?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bos45430
Forum Newbie
Posts: 12
Joined: Sun Jul 08, 2007 11:11 am

Checking if a variable has been set?

Post by bos45430 »

Could anyone tell me how to check if a variable has been assigned a value. I want to make it where my code checks to see if they filled out a text field or not.

THanks for your help

John
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

empty();
isset();
bos45430
Forum Newbie
Posts: 12
Joined: Sun Jul 08, 2007 11:11 am

Post by bos45430 »

right on. exactly what i was looking for. THANKS!
designerman
Forum Newbie
Posts: 4
Joined: Mon Jul 09, 2007 5:47 am

Post by designerman »

you can also check for if($foo == ""){ // contained nothing } becuase you may set a var in your code before and check for this

You can clear the contents of a var by using the empty function
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

designerman wrote:you can also check for if($foo == ""){ // contained nothing } becuase you may set a var in your code before and check for this

You can clear the contents of a var by using the empty function
Please be careful with you posts. Zoxive posted the valid answer. Your proposition isn't really good.
Post Reply