Determining if a variable is blank.
| From: | Jason | Date: | Thu, 22 Aug 2002 02:36:49 +0000 |
| Subject: | Determining if a variable is blank. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-113591@lists.php.net to get a copy of this message | ||
I have a simplistic forum, and I am trying to write some code to determine
if the message box actually contains information, because if it is blank I
obviously don't want to post it to the database. The message box has the
name of 'reply'. Here is the code I'm trying to use, but its not working:
$reply2 = str_replace(" ","",$reply);
if(empty($reply2)){
// echo some error message to the user that they can't post a blank message
}
else{
// post the message
}
This however didn't work for me. So I had the thought that maybe the
variable $reply2 isn't set because it is blank. So I tried this:
$reply2 = str_replace(" ","",$reply);
if(empty($reply2) || !isset($reply2)){
// echo an error message
}
else{
// post the message.
}
I've tried different variations on this same idea, but somehow none of them
are working. Can anyone give me any suggestions or insight?
Jason Cathcart
Check Out My Site: http://www.biohazardous.org