Re: Two very useful PHP functions

From: Date: Thu, 30 Apr 2009 08:15:33 +0000
Subject: Re: Two very useful PHP functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-292143@lists.php.net to get a copy of this message
'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/]

« previous php.general (#292143) next »