Re: Is there a shorthand way to...?
| From: | Robby Russell | Date: | Mon, 22 Nov 2004 14:27:46 +0000 |
| Subject: | Re: Is there a shorthand way to...? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-202675@lists.php.net to get a copy of this message | ||
On Mon, 2004-11-22 at 09:01 -0500, Al wrote:
> When handling $_POST[] values that may or may not be assigned, I am forever using:
>
> if((isset($_POST['courses_list']) AND $_POST['courses_list']==
> 'Used'))
>
> Is there a shorthand way of doing this without causing notice errors?
>
> Thanks.....
>
You could write a function that would perform this for you.
function getPostVar($var)
{
if (array_key_exists($var, $_POST) && isset($_POST[$var])) {
return $_POST[$var];
} else {
return False;
}
}
if (getPostVar('contact_list') == "Used")...
--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now supporting PHP5 ---
****************************************/
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc