M. Sokolewicz wrote: >> $x = (isset($ANY_var) ? $ANY_var : 'Default Value'); >> by >> $x = ifsetor($ANY_var, 'Default Value'); >>
I must say I fully agree; I don't see any use in putting extra functions in the PHP namespace just because people don't want to type a couple of extra characters.
it is not "a few extra characters", its "needless duplication of characters", and the number of characters multiplies with the number of uses of the construct please keep in mind that $ANY_var can be a variable name of any length or an element of a multidimensional array. this can leed to unreadably long statements, hard to track down copy errors and is a maintainance nichtmare as you always have to change things in two places at the same time How quick can you spot the error in the following assignment? And if you didn't know the context: how long would it take you to find out what it does? $x = (isset($config['general']['foo']['bar']['somelist']) ? $config['general']['foo']['bar']['sonelist'] : "default"); On the other hand the meaning of $x = ifsetor($config['general']['foo']['bar']['somelist'], "default"); is pretty clear, only about half as long and way less error prone. I don't really like the name 'ifsetor' but i *love* the concept and given that there is no proper way to implement this function in user space i'm perfectly in favor of its addition. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php