Yet another feature request

From: Date: Fri, 10 Nov 2006 13:26:15 +0000
Subject: Yet another feature request
Groups: php.internals 
Request: Send a blank email to internals+get-26465@lists.php.net to get a copy of this message
Hi, I see this is the time to do language feature request. So let me add another. I very often use something like: /$a = isset($x['abc']) ? //$x['abc'] : null; /This is to prevent an E_NOTICE from being thrown. This subject is already discussed many times, which led to a suggestion for PHP6 (http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for-foo-isset-foo-foo-something-else) /$foo = $_GET['foo'] ?: 42;/ This still throws an E_NOTICE when the first parameter is not set. Also $foo will be set to 42 if the input variable is 0. The conclusion is that this feature is useless for the presented situation. I would like something similar to isset: ifsetor($var, [$default = null]); /$a = ifsetor($x['abc']); //$foo = ifsetor($_GET['foo'], 42); / I believe adding this feature will remove the biggest con people have on working with E_NOTICE enabled. I'm sorry if I reopen an already closed subject. Best regards, Arnold

« previous php.internals (#26465) next »