rfc:var-export-array-syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:var-export-array-syntax [2020/04/08 12:53] – googleguy | rfc:var-export-array-syntax [2020/04/09 22:32] – googleguy | ||
---|---|---|---|
Line 12: | Line 12: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This change proposes 3 new bit-wise optional flags for '' | + | This change proposes 3 new bit-wise optional flags for '' |
- VAR_EXPORT_SHORT_ARRAY | - VAR_EXPORT_SHORT_ARRAY | ||
- VAR_EXPORT_NO_INDEX | - VAR_EXPORT_NO_INDEX | ||
- | - VAR_EXPORT_NO_WHITESPACE | + | - VAR_EXPORT_COMPACT |
- | '' | + | '' |
Instead of | Instead of | ||
- | <code php> | + | <code php> |
+ | array ( | ||
+ | 0 => 1, | ||
+ | 1 => 2, | ||
+ | 2 => 3, | ||
+ | ) | ||
+ | </ | ||
- | '' | + | '' |
- | <code php>[1, 2, 3]</ | + | <code php> |
+ | [ | ||
+ | 0 => 1, | ||
+ | 0 => 2, | ||
+ | | ||
+ | ] | ||
+ | </ | ||
This will effect things like '' | This will effect things like '' | ||
Line 46: | Line 58: | ||
' | ' | ||
) | ) | ||
+ | */ | ||
//With the new change it would be | //With the new change it would be | ||
- | var_export($obj, | + | var_export($obj, false, VAR_EXPORT_SHORT_ARRAY); |
/* | /* | ||
Line 79: | Line 91: | ||
//With the changes it would be: | //With the changes it would be: | ||
- | var_export(new Foo, VAR_EXPORT_SHORT_ARRAY); | + | var_export(new Foo, false, VAR_EXPORT_SHORT_ARRAY); |
/* | /* | ||
Line 86: | Line 98: | ||
]) | ]) | ||
*/ | */ | ||
+ | </ | ||
+ | |||
+ | Using the other bitwise flags you can also do things like... | ||
+ | |||
+ | <code php> | ||
+ | var_export([1, | ||
+ | |||
+ | /* | ||
+ | outputs: | ||
+ | | ||
+ | [1, 2, 3] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | |||
+ | /* | ||
+ | outputs: | ||
+ | | ||
+ | [0 => 1, 1 => 2, 2 => 3] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | |||
+ | /* | ||
+ | outputs: | ||
+ | | ||
+ | [ | ||
+ | 1, | ||
+ | 2, | ||
+ | 3 | ||
+ | ] | ||
+ | */ | ||
+ | |||
+ | |||
</ | </ | ||
Line 123: | Line 169: | ||
https:// | https:// | ||
+ | |||
+ | https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
rfc/var-export-array-syntax.txt · Last modified: 2020/04/10 09:24 by guilliamxavier