Re: Is there a shorthand way to...?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
*    --- Now supporting PHP5 ---
****************************************/

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux