Oh, please, by no means take that as an endorsement for dropping error reporting levels. It was just an observation of how PHP actually derives a conditional in those situations. It’s not as if there’s a fatality in script execution when you make that kind of comparison, it’s just a really shitty way to code. In fact, it’s also why i typically avoid empty(). Nevertheless, PHP lacks a concise solution for dealing with multiple possibly-false-evaluating values.
Hacks like my coalesce() function that rely on the side effect of reference-passing can only go so far, as there’s also no way to pass &N references (at least that I’m aware of, correct me if I’m wrong) I mean really I just want to be able to easily and lazily handle situations where I’ve got several vars as possible values in an assignment or expression, without chaining lots of function calls. Perhaps if empty() took N params like isset() does, but that’s only a nudge in the, er, “right” direction. > On Nov 23, 2015, at 12:03 PM, Levi Morrison <le...@php.net> wrote: > >> In practice, you can ignore E_NOTICE and php will happily treat null and >> !isset() as the same thing in *most* cases, so that’s not a good indicator >> of truthiness. > > > If you really believe that then this is all you need already: > > $database = $config['database'] ?: 'db'; > > Correct? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php