PHP: Making sure a variable in't empty?

They have: 850 posts

Joined: Jul 1999

I need to make sure that a few inputed variables are not blank. By empty, I mean containing just spaces. so "", " ", " " would be considered empty.

I have tried
$var = " ";
if(!empty($var)
if(isset($var)
etc, but php still thinks that the variable has "stuff" in it, even if it only consists of white spaces.

Any ideas?
Thanks

------------------
click here to help save lives
http://www.wiredstart.com : The Technology Start Page

[This message has been edited by robp (edited 17 May 2000).]

They have: 453 posts

Joined: Jan 1999

ouch ...

!$xxx
is TRUE if $xxx = "0";

I would go with something like

if( ereg( "^[ ]*", $xxx ) ){
// empty
}

You might want to add tabs and newlines to the class, but that depends on from where the data came.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.