php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68979 var_export generates useless empty string
Submitted: 2015-02-03 14:37 UTC Modified: 2018-10-02 11:09 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: chris dot kde at gmail dot com Assigned:
Status: Wont fix Package: Variables related
PHP Version: 5.6.5 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-02-03 14:37 UTC] chris dot kde at gmail dot com
Description:
------------
Hello,
var_export generates useless empty string in some specials cases (tested on 5.6.2)

Test script:
---------------
$data = "\0\0\0\0\0\0\0";
var_export($data);

echo "\n\n";

$data = "ok\0\0\0ab";
var_export($data);

Expected result:
----------------
"\0\0\0\0\0\0\0"

'ok' . "\0\0\0" . 'ab'

Actual result:
--------------
'' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . ''

'ok' . "\0" . '' . "\0" . '' . "\0" . 'ab'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-27 05:15 UTC] yohgaki@php.net
http://3v4l.org/hsMCN

Older PHP escaped NULL to \000.
 [2018-09-23 12:41 UTC] cmb@php.net
> Older PHP escaped NULL to \000.

However, that was wrong since it was a single-quoted string. This
issue had been reported as bug #42272, and fixed with commit
63dcbb7[1] and dc30b00[2], which introduced the overly verbose but
correct output.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=63dcbb73f0223f98c8666cee15e73a60891e0191>
[2] <http://git.php.net/?p=php-src.git;a=commit;h=dc30b0035d098b6e982c432c8d81919524f1d9fd>
 [2018-10-02 11:09 UTC] yohgaki@php.net
-Status: Open +Status: Wont fix
 [2018-10-02 11:09 UTC] yohgaki@php.net
Indeed. Won't fix would be appropriate.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Mar 03 18:01:24 2021 UTC