rfc:var-export-array-syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
rfc:var-export-array-syntax [2020/04/09 22:32] – 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 | ||
Line 18: | Line 18: | ||
- VAR_EXPORT_COMPACT | - VAR_EXPORT_COMPACT | ||
- | '' | + | '' |
+ | Each option can be used alone, and can also be combined with other(s). | ||
- | Instead of | + | |
+ | For example, < | ||
<code php> | <code php> | ||
Line 31: | Line 33: | ||
</ | </ | ||
- | '' | + | and the new <php>var_export([1, |
<code php> | <code php> | ||
[ | [ | ||
0 => 1, | 0 => 1, | ||
- | | + | |
- | | + | |
] | ] | ||
</ | </ | ||
- | This will effect things like '' | + | This would affect |
- | So the following changes | + | So the following changes |
<code php> | <code php> | ||
Line 51: | Line 53: | ||
var_export($obj); | var_export($obj); | ||
- | |||
/* | /* | ||
- | Gives us: | ||
(object) array( | (object) array( | ||
' | ' | ||
Line 59: | Line 59: | ||
) | ) | ||
*/ | */ | ||
- | |||
- | //With the new change it would be | ||
var_export($obj, | var_export($obj, | ||
- | |||
/* | /* | ||
(object) [ | (object) [ | ||
Line 72: | Line 69: | ||
</ | </ | ||
- | The same happens | + | Same for other classes: |
<code php> | <code php> | ||
Line 80: | Line 77: | ||
var_export(new Foo); | var_export(new Foo); | ||
- | |||
/* | /* | ||
- | Gives us: | ||
Foo:: | Foo:: | ||
' | ' | ||
)) | )) | ||
*/ | */ | ||
- | |||
- | |||
- | //With the changes it would be: | ||
var_export(new Foo, false, VAR_EXPORT_SHORT_ARRAY); | var_export(new Foo, false, VAR_EXPORT_SHORT_ARRAY); | ||
- | |||
/* | /* | ||
Foo:: | Foo:: | ||
Line 100: | Line 91: | ||
</ | </ | ||
- | Using the other bitwise flags you can also do things like... | + | Using the other bitwise flags you could also do things like... |
<code php> | <code php> | ||
- | var_export([1, | + | var_export([1, |
+ | /* | ||
+ | array ( | ||
+ | 1, | ||
+ | 2, | ||
+ | 3, | ||
+ | ) | ||
+ | */ | ||
+ | var_export([1, | ||
/* | /* | ||
- | outputs: | + | array (0 => 1, 1 => 2, 2 => 3) |
- | + | ||
- | [1, 2, 3] | + | |
*/ | */ | ||
+ | </ | ||
- | var_export([1, | + | and combine them... |
+ | <code php> | ||
+ | var_export([1, | ||
/* | /* | ||
- | outputs: | + | [ |
- | | + | 1, |
- | [0 => 1, 1 => 2, 2 => 3] | + | |
+ | | ||
+ | ] | ||
*/ | */ | ||
- | var_export([1, | + | var_export([1, |
+ | /* | ||
+ | [0 => 1, 1 => 2, 2 => 3] | ||
+ | */ | ||
+ | var_export([1, | ||
/* | /* | ||
- | outputs: | + | array (1, 2, 3) |
- | + | ||
- | [ | + | |
- | | + | |
- | | + | |
- | | + | |
- | ] | + | |
*/ | */ | ||
+ | var_export([1, | ||
+ | /* | ||
+ | [1, 2, 3] | ||
+ | */ | ||
</ | </ | ||
rfc/var-export-array-syntax.1586471542.txt.gz · Last modified: 2020/04/09 22:32 by googleguy