> -----Original Message----- > From: Logan McKinley [mailto:[EMAIL PROTECTED] > Sent: 17 June 2003 19:55 > > right now if a the 'field' key does not exist at all in the > querystring it > returns the following error: > Notice: Undefined index: Register in > c:\inetpub\wwwroot\PHP\Register.php on > line 3 > I think i can use the empty function but i pass in 11 > different variables > and it seems like there must be a more eligant way to prevent > the error then > with 11 individual if statements. Is there a way in which it > will return a > value even if the key does not exist in the querystring.
Yes -- you can use the @ silence operator: @$_GET['field'] will silently return NULL if the index 'field' doesn't exist in the $_GET array (or if the $_GET array itself doesn't exist!). Some might regard this as a kludge, but I don't see it that way -- if the operator is provided as part of the language, using it knowledgeably and judiciously seems like a perfectly valid technique to me. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php