On Wed, Apr 20, 2011 at 04:55:00PM +0200, Mark wrote: > Hi, > > This proposal is for the often called line like this: > $var = isset($_GET['var']) ? $_GET['var'] : ''; > > Only a shorter and imho a cleaner solution to get the same: > $var = varset($_GET['var']);
It should be called var_set() - better on name space pollution. > However there is a slight issue with this approach. If notices are turned on > this code will generate a notice while i think it should not do that. But > perhaps this approach is "to short". > A slightly different implementation (and longer) prevents the notice: If is is a language element (like isset()) then you can avoid this problem. I do find a lot of code, in simple scripts, that does just that. It might be nice to extend it such that if the 1st argument is a list then the first in the list which is set is returned, eg: $var = var_set(($_GET['var'], $_POST['var']), 'default'); -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include <std_disclaimer.h> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php