rfc:isset-set-operator
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:isset-set-operator [2013/11/30 16:05] – chrislondon | rfc:isset-set-operator [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Date: 2013-11-24 | * Date: 2013-11-24 | ||
* Author: Chris London, me chrislondon co | * Author: Chris London, me chrislondon co | ||
- | * Status: Draft | + | * Status: Draft (Inactive) |
===== Introduction ===== | ===== Introduction ===== | ||
Line 20: | Line 20: | ||
| | ||
// or | // or | ||
- | if (!isset($foo) | + | if (!isset($foo) |
+ | |||
+ | ??: will be equivalent to the ternary short hand ?: except that it also checks for isset(). | ||
+ | |||
+ | // $bar is unset | ||
+ | |||
+ | $foo = $bar ?: ' | ||
+ | |||
+ | $foo = $bar ??: ' | ||
+ | |||
+ | // ??: is functionally equivalent to: | ||
+ | $foo = (isset($bar) && $foo) ? $bar : $other; | ||
+ | |||
+ | This will be very helpful for echoing default variables in HTML like so: | ||
+ | |||
+ | <div class="<? | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 36: | Line 51: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | To be added | + | **Possible Alternatives |
+ | |||
+ | - ?:= | ||
+ | - ||= | ||
+ | - @= | ||
+ | |||
+ | **Possible Alternatives To ??: Operator** | ||
+ | |||
+ | - ?:: | ||
+ | - ?: (backward compatibility concerns) | ||
+ | - || (backward compatibility concerns) | ||
+ | - @: | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== |
rfc/isset-set-operator.1385827521.txt.gz · Last modified: 2017/09/22 13:28 (external edit)