Skip to content

@sobstel /ternary_operator_gotcha.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
PHP new ternary operator gotcha
<?php
// 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.