Answer the question
In order to leave comments, you need to log in
Why does var_export "frame" null bytes with empty strings?
<?php
echo var_export("\0", true);
'' . "\0" . ''
"\0"
Answer the question
In order to leave comments, you need to log in
You assume too smart logic for a stupid function.
https://github.com/php/php-src/blob/PHP-7.2/ext/st...
var_export tries to output a string in single quotes so that special characters and other goodies are not substituted in it. But null-byte therefore cannot be displayed in single quotes. Therefore, all \0 are replaced with ' . \"\\0\" . '
In the extreme case, just single quotes are obtained at the edges of the resulting string and ' . \"\\0\" . ' as the main data. And checking beforehand that we only have \0 in the string is too special a case.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question