Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHP new ternary operator gotcha
// old way
$value = $value ? $value : false;
// new way
$value = $value ?: false;
// however...
$value = isset($value) ?: false; // if eg. $value="value", then it returns (bool)true, and not (string)"value"
Copy link

charlie-wasp commented Sep 3, 2015

This one got me now :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment