Re: !isset ??

From: Date: Wed, 06 Feb 2002 20:31:59 +0000
Subject: Re: !isset ??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83748@lists.php.net to get a copy of this message
If your purpose is to see if an user wrote or selected anything, you can do: if (ereg("^[[:blank:]]*$",$_POST['var'])) { // It has only spaces } I am sorry if does not fit your need like I interpreted. But, just for not getting flamed, !isset() works fine for me on both cases (so far where I tested); -- Julio Nobrega. Um dia eu chego lá: http://sourceforge.net/projects/toca Ajudei? Salvei? Que tal um presentinho? http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884 "Erik Price" <pricee@hhbrown.com> wrote in message news:0C6A07A3-1B3D-11D6-A011-0050E4857868@hhbrown.com... > Hm. I hope I'm not opening an old wound: > > Curious about the proper way to test for the existence of a variable, I > decided to read up on isset() at php.net's function manual pages. It > seems at first to be a way to test whether or not a variable has been > set. > > But reading the annotations below the documentation is mind boggling. > Back and forth, it seems to go -- and then to find out that one method > is to be used to test for POSTed variables, and another to be used for > GETted variables (for $_POST, use "$_POST['var'] !='' ", and for > $_GET, > use "!isset($_GET['var'])"). > > Pretty confusing. Can anyone shed some light on whether or not there is > a final definite way to do this? I've used (!($_POST['var'])) with no > problems in the past, but does good coding style suggest that I use > (!isset($_POST['var'])) now? > > > Erik > > > > > > ---- > > Erik Price > Web Developer Temp > Media Lab, H.H. Brown > pricee@hhbrown.com >

« previous php.general (#83748) next »