Re: Proposal: short_var_export($value, bool $return=false, int $flags=0)

From: Date: Thu, 21 Jan 2021 10:43:27 +0000
Subject: Re: Proposal: short_var_export($value, bool $return=false, int $flags=0)
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-112953@lists.php.net to get a copy of this message
> Le 21 janv. 2021 à 00:19, Sara Golemon <pollita@php.net> a écrit : > > IMO print_r/var_dump should be kept out of this discussion. Those are human > readable outputs for human consumption. var_export() is about a machine > readable output for recreating initial state within a runtime. The > requirements presented are wholly different. > > -Sara If the goal of var_export is *only* to have some machine-readable output, the following will do it: <?php function my_var_export(mixed $x): string { $serialized = \base64_encode(\serialize($x)); return "\\unserialize(\\base64_decode('$serialized'))"; } ?> In reality, the output of var_export() is *both* machine-readable and human-readable. —Claude

« previous php.internals (#112953) next »