Re: Two very useful PHP functions

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

 



This was discussed for PHP6, but eventually decided not to have such a
function. Instead, we now have the following:    $var = $_GET['var'] ?: 5;

Taken from http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html

'you'd be able to do something like this: "$foo = $_GET['foo'] ?: 42;" (i.e.
if foo is true, $foo will equal 42).'


2009/5/1 Raymond Irving <xwisdom@xxxxxxxxx>

>
> Hi Colin and Daniel,
>
> Thanks for the feedback.
>
> I know that this functionality can be added to a framework or a stand alone
> function but I'm assuming that we would not get the same performance:
>
> Case 1
> -----------
> $c = isset($a) ? $a : '';
> // total time = overhead  of isset() + overhead of ?:
>
> Case 2
> -----------
> $c = myWrapper($a,$b)
> // total time = overhead of myWrapper() + overhead of isset() + overhead of
> ?:
>
> Case 3
> -----------
> $c = ifset($a,$b)
> // total time = overhead of ifset()
>
>
>
> Best regards
>
> __
> Raymond Irving
>
> --- On Thu, 4/30/09, Daniel Brown <danbrown@xxxxxxx> wrote:
>
> > From: Daniel Brown <danbrown@xxxxxxx>
> > Subject: Re:  Two very useful PHP functions
> > To: "Raymond Irving" <xwisdom@xxxxxxxxx>
> > Cc: php-general@xxxxxxxxxxxxx
> > Date: Thursday, April 30, 2009, 11:37 AM
> > On Wed, Apr 29, 2009 at 22:32,
> > Raymond Irving <xwisdom@xxxxxxxxx>
> > wrote:
> > >
> > > What do you think? Can they make it into 5.3?
> >
> >     Not when doing the ternary operator that you
> > even displayed
> > yourself takes up less code and time than a core function
> > would.  It's
> > a good idea, but better handled on the frontend of
> > things.  You may
> > want to consider contributing that to a framework, which is
> > where it
> > would be more appropriate.
> >
> > --
> > </Daniel P. Brown>
> > daniel.brown@xxxxxxxxxxxx
> > || danbrown@xxxxxxx
> > http://www.parasane.net/ || http://www.pilotpig.net/
> > 50% Off All Shared Hosting Plans at PilotPig: Use Coupon
> > DOW10000
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[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