rfc:var-export-array-syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:var-export-array-syntax [2020/04/08 12:53] – googleguy | rfc:var-export-array-syntax [2020/04/10 09:24] (current) – typos, examples guilliamxavier | ||
---|---|---|---|
Line 12: | Line 12: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This change proposes | + | This change proposes |
- VAR_EXPORT_SHORT_ARRAY | - VAR_EXPORT_SHORT_ARRAY | ||
- VAR_EXPORT_NO_INDEX | - VAR_EXPORT_NO_INDEX | ||
- | - VAR_EXPORT_NO_WHITESPACE | + | - VAR_EXPORT_COMPACT |
- | '' | + | '' |
+ | Each option can be used alone, and can also be combined with other(s). | ||
- | Instead of | ||
- | <code php>array(1, 2, 3)</code> | + | For example, |
- | '' | + | <code php> |
+ | array ( | ||
+ | 0 => 1, | ||
+ | 1 => 2, | ||
+ | 2 => 3, | ||
+ | ) | ||
+ | </ | ||
- | <code php>[1, 2, 3]</code> | + | and the new <php>var_export([1, 2, 3], false, VAR_EXPORT_SHORT_ARRAY); |
- | This will effect things like '' | + | <code php> |
+ | [ | ||
+ | 0 => 1, | ||
+ | 1 => 2, | ||
+ | 2 => 3, | ||
+ | ] | ||
+ | </ | ||
- | So the following changes | + | This would affect '' |
+ | |||
+ | So the following changes | ||
<code php> | <code php> | ||
Line 39: | Line 53: | ||
var_export($obj); | var_export($obj); | ||
- | |||
/* | /* | ||
- | Gives us: | ||
(object) array( | (object) array( | ||
' | ' | ||
' | ' | ||
) | ) | ||
+ | */ | ||
- | + | var_export($obj, false, VAR_EXPORT_SHORT_ARRAY); | |
- | //With the new change it would be | + | |
- | + | ||
- | var_export($obj, | + | |
/* | /* | ||
(object) [ | (object) [ | ||
Line 60: | Line 69: | ||
</ | </ | ||
- | The same happens | + | Same for other classes: |
<code php> | <code php> | ||
Line 68: | Line 77: | ||
var_export(new Foo); | var_export(new Foo); | ||
- | |||
/* | /* | ||
- | Gives us: | ||
Foo:: | Foo:: | ||
' | ' | ||
Line 76: | Line 83: | ||
*/ | */ | ||
- | + | var_export(new Foo, false, VAR_EXPORT_SHORT_ARRAY); | |
- | //With the changes it would be: | + | |
- | + | ||
- | var_export(new Foo, VAR_EXPORT_SHORT_ARRAY); | + | |
/* | /* | ||
Foo:: | Foo:: | ||
' | ' | ||
]) | ]) | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | Using the other bitwise flags you could also do things like... | ||
+ | |||
+ | <code php> | ||
+ | var_export([1, | ||
+ | /* | ||
+ | array ( | ||
+ | 1, | ||
+ | 2, | ||
+ | 3, | ||
+ | ) | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | array (0 => 1, 1 => 2, 2 => 3) | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | and combine them... | ||
+ | |||
+ | <code php> | ||
+ | var_export([1, | ||
+ | /* | ||
+ | [ | ||
+ | 1, | ||
+ | 2, | ||
+ | 3, | ||
+ | ] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | [0 => 1, 1 => 2, 2 => 3] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | array (1, 2, 3) | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | [1, 2, 3] | ||
*/ | */ | ||
</ | </ | ||
Line 123: | Line 172: | ||
https:// | https:// | ||
+ | |||
+ | https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
rfc/var-export-array-syntax.1586350435.txt.gz · Last modified: 2020/04/08 12:53 by googleguy