> -----Original Message----- > From: Adam Richardson [mailto:simples...@gmail.com] > Sent: 08 April 2011 08:02
> > Indeed. > > The '?' character already is special, so using '??' seems like a > safe, > practical approach. However, I'd prefer maintaining the form of the > standard > ternary operator with the colon ($value = $var['bar'] ?? : 'Bar was > not > set'; // value ="Bar was not) so the '??' operator could be applied > in any > situation that one would normally use the standard ternary operator. > > // standard > $value = isset($a[$key]) ? $a[$key] : 'Not set'; > > // new ?? double ternary that performs isset check and omits second > expression > $value = $a[$key] ?? : 'Not set'; > > // new ?? double ternary that performs isset check and uses second > expression > $value = $a[$key] ?? strtoupper($a[$key]) : 'Not set'; > Like it! I would have proposed ??: for the isset() variant of ?:, and I think decomposing it into a full ternary operator in this way, with ??: as a degenerate variant, is brilliant. (Only downside is, people would have to stop referring to *the* ternary operator!) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507 City Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php