'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

Reply via email to