Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16649 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78398 invoked by uid 1010); 14 Jun 2005 04:37:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78383 invoked from network); 14 Jun 2005 04:37:38 -0000 Received: from unknown (HELO botimer.net) (127.0.0.1) by localhost with SMTP; 14 Jun 2005 04:37:38 -0000 X-Host-Fingerprint: 64.202.165.194 smtpout02-04.prod.mesa1.secureserver.net Linux 2.4/2.6 Received: from ([64.202.165.194:38552] helo=smtpout02-04.prod.mesa1.secureserver.net) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id C3/28-20931-21F5EA24 for ; Tue, 14 Jun 2005 00:37:38 -0400 Received: (qmail 13109 invoked from network); 14 Jun 2005 04:37:34 -0000 Received: from unknown (66.188.29.245) by smtpout02-04.prod.mesa1.secureserver.net (64.202.165.194) with ESMTP; 14 Jun 2005 04:37:34 -0000 In-Reply-To: <42AE5845.70307@kmit.sk> References: <5.1.0.14.2.20050603203711.028e9140@localhost> <200506051859.53976.magnus@php.net> <6E.27.21296.C90E7A24@pb1.pair.com> <38.CE.21296.BFD78A24@pb1.pair.com> <43.34.20931.17BEDA24@pb1.pair.com> <1118701987.27553.6.camel@blobule.suds> <53F92510-14F5-4E4E-939F-8FC382A7B925@botimer.net> <87728790.20050613214458@ionzoft.com> <42AE5845.70307@kmit.sk> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed Message-ID: <42841E3E-21B9-4007-9B6C-A6A1E3FE8A0D@botimer.net> Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Jun 2005 00:37:37 -0400 To: =?UTF-8?Q?Ondrej_Ivani=C4=8D?= , Jason Garber X-Mailer: Apple Mail (2.730) Subject: Re: [PHP-DEV] PHP 5.1 From: noah@botimer.net (Noah Botimer) Ondrej and Jason, Just pondering the proposed coalesce() variants in the context of =20 Ondrej's scenario I came upon two thoughts. I forgot to mention the nice single parameter case of a coalesce() =20 function like this, which would return null if not set: $x =3D coalesce($REQUEST['x']); Also, the same characteristics could be easily preserved, as far as =20 warnings and errors, by not passing any unset variables to the =20 callback in a ucoalesce() function call: $x =3D ucoalesce("is_number", $REQUEST['x']); With that assertion, is_number() would only be called if the request =20 variable were set, otherwise returning null, modeling the ternary =20 expression you included, Ondrej. Thanks, -Noah On Jun 14, 2005, at 12:08 AM, Ondrej Ivani=C4=8D wrote: > Jason Garber wrote: > >> ifsetor is NOT input filtering, it is not a complex, general =20 >> purpose >> > > stuff like 'ifsetof()' is good when is use as: > > >> $x =3D ifsetor($ANY_var, 'Default Value'); >> > > but too many times I need additional checks like this: > > $x =3D isset($_REQUEST['x']) && is_number($x) ? $_REQUEST['x'] : null; > > It's possible to add additional third parameter to ifsetof() ? > > ifsetof(variable, expression [, callback]) > > callback is a function which take one argument (value of variable) and > return true or false. If return false 'expression' will be return from > ifsetor(). > > Usage: > > $x =3D ifsetor($_REQUEST['x'], null, 'is_number'); > > >> It needs to be fast, and simple. >> > > Hm... It's simple, but It's not very clean at first look. > > What's your opinion? > > --=20 > Ondrej Ivnaic > (ondrej@kmit.sk) > > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > >