According to the PHP Manual, on the var_export
function
var_export()
gets structured information about a given variable. She is similar tovar_dump()
with one exception: the returned representation is a valid PHP code.
That is, it should return a valid PHP code for a given value passed by parameter.
The problem is that in PHP 5.4, the settings for a array
have changed. You no longer need to use the keyword array
, but only use the square brackets.
Example:
// Versões anteriores ao PHP 5.4
$a = array(1, 2, 3);
// Versões iguais ou posteriores ao PHP 5.4
$a = [1, 2, 3]
When I do the var_export
in this same array (even in PHP 5.4), it returns me this:
array ( 0 => 1, 1 => 2, 2 => 3, )
I would like var_export
to return the array like this:
[ 0 => 1, 1 => 2, 2 => 3, ]
Is there any way to resolve this?
Has PHP already fixed this in newer versions?