rfc:list_default_value
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:list_default_value [2015/11/09 13:33] – reeze | rfc:list_default_value [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 9: | Line 9: | ||
We could destruct variables from an array with [[http:// | We could destruct variables from an array with [[http:// | ||
- | For the similar | + | For the similar |
Some clever users figured out some workaround like this [[http:// | Some clever users figured out some workaround like this [[http:// | ||
Line 15: | Line 15: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Support new syntax to set default | + | Support new syntax to set default |
<code php> | <code php> | ||
+ | // basic syntax | ||
list($a, $b=' | list($a, $b=' | ||
list($a, $b=' | list($a, $b=' | ||
+ | |||
+ | // comparation | ||
+ | list($a, list($b=1, $c=2)) = $arr; | ||
+ | // or we need to check it ourself | ||
+ | if (!isset($arr[1][0])) { | ||
+ | $arr[1][0] = 1; | ||
+ | } | ||
+ | if (!isset($arr[1][1])) { | ||
+ | $arr[1][0] = 2; | ||
+ | } | ||
+ | |||
+ | list($a, list($b, $c)) = $arr; | ||
+ | // other examples | ||
function say_hello() | function say_hello() | ||
{ | { | ||
Line 37: | Line 51: | ||
<code php> | <code php> | ||
- | list($a, $b='deafult') = $arr; | + | list($a, $b='default') = $arr; |
// equals | // equals | ||
Line 81: | Line 95: | ||
===== RFC Impact ===== | ===== RFC Impact ===== | ||
- | ==== To SAPIs ==== | ||
- | No impact | ||
- | |||
- | ==== To Existing Extensions ==== | ||
- | No impact | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
I am working on opcache compatibility. | I am working on opcache compatibility. | ||
- | |||
- | ==== New Constants ==== | ||
- | None | ||
- | |||
- | ==== php.ini Defaults ==== | ||
- | None | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
None for now | None for now | ||
- | |||
- | ===== Unaffected PHP Functionality ===== | ||
- | No BC break | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | |||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
rfc/list_default_value.1447076020.txt.gz · Last modified: 2017/09/22 13:28 (external edit)