[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    [PHP]  Re: Two very useful PHP functions
From:       Colin Guthrie <gmane () colin ! guthr ! ie>
Date:       2009-04-30 8:15:33
Message-ID: gtbmn5$kq4$1 () ger ! gmane ! org
[Download RAW message or body]

'Twas brillig, and Raymond Irving at 30/04/09 03:32 did gyre and gimble:
> Hello,
> 
> Every so often I have to be using the isset() function to check if a variable \
> exists. It would be useful to have something like an ifset() function 
> Instead of doing this
> 
> $v = isset($input) ? $input : $default;
> 
> we can do this
> 
> $v = ifset($input,$default); 
> // returns $input if it exists otherwise it will return $default
> 
> We could also do the same for the empty() function. So instead of doing this
> 
> $v = empty($input) ? $default : $input;
> 
> we can do this
> 
> $v = ifempty($input,$default);
> // returns $input if it is not empty otherwise it will return $default
> 
> What do you think? Can they make it into 5.3?

To be honest, I don't see the compelling need for this.

I don't disagree that the functionality is nice, however I quite like 
the verbose versions as they are clearer to understand without knowing 
an API function.

Also, most of the cases that you would use these functions are with 
input from GET args and the like. Most frameworks provides wrappers for 
this with handy ways to get the defaults etc.

So overall, I can't see this becoming a core PHP feature.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
   Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
   Mandriva Linux Contributor [http://www.mandriva.com/]
   PulseAudio Hacker [http://www.pulseaudio.org/]
   Trac Hacker [http://trac.edgewall.org/]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic