> Le 21 janv. 2021 à 00:19, Sara Golemon <poll...@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

Reply via email to