[thelist] undefined php variable

Tom Dell'Aringa pixelmech at yahoo.com
Thu Jul 31 13:23:44 CDT 2003


--- Simon Willison <cs1spw at bath.ac.uk> wrote:

> I always use the following idiom to avoid warnings like that:
> $aDate = isset($_POST['postdate']) ? $_POST['postdate'] : false;
> 
> That sets $aDate to the data from $_POST['postdata'] if it has been
> sent, and otherwise sets it to false.

Hmm. I see what you are getting after, but in some cases wouldn't
this be a bad thing for me? Case in point, When this particular page
loads it always grabs my $_POST values and places them into the form.
If its your first time there, the form is empty because the values
are empty (which is what I want).

If I do the above, my form fields will all have "false" in them, or I
have to put some logic before the field to say 'if its false, its
blank'. (the page posts to itself)

Also, if I want to check if my var has a value, can't I just do the

if(isset($var)) if/when I need to check for its value?

I'm no php guru, so just asking :)

Tom

=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: Premium Content Author / JavaScript / Every Friday!
http://www.maccaws.com/ :: Group Leader
[Making A Commercial Case for Adopting Web Standards]

"That's not art, that's just annoying." -- Squidward


More information about the thelist mailing list