php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66053 var_Export / var_dump error
Submitted: 2013-11-07 20:21 UTC Modified: 2013-11-07 20:34 UTC
From: remco dot pc at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.5.5 OS: Windows 7
Private report: No CVE-ID: None
 [2013-11-07 20:21 UTC] remco dot pc at gmail dot com
Description:
------------
when useing var_dump or var_export with the following code it goes wrong:

$nr = 0;
var_dump('test:'. $nr + 1); // result = int(1)
var_export('test:'. $nr +1); //result = int(1)

//expected string 'test:1'

var_dump('test:' . $nr);  // result = 'test:0' string(6)
var_export('test:') . $nr); // result = 'test:0' string(6)

//ok





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-07 20:24 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2013-11-07 20:24 UTC] requinix@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Operator precedence: "test:".$nr+1 => ("test:".$nr)+1 => 1

You want
var_dump('test:' . ($nr + 1));
var_export('test:' . ($nr + 1));
 [2013-11-07 20:34 UTC] remco dot pc at gmail dot com
ok thanks for the explanation
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 19:00:01 2026 UTC