Edit report at https://bugs.php.net/bug.php?id=30471&edit=1
ID: 30471
Comment by: patrick at infranet dot com
Reported by: none at example dot com
Summary: var_export: Nesting level too deep - recursive
dependency?
Status: Not a bug
Type: Bug
Package: PHP options/info functions
Operating System: Linux
PHP Version: 5.0.2
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
Another option would be to have var_export always produce some output and then
limit the output to some level of recursion (settable by user, but defaulting
to
some minimum safe but useful value).
Previous Comments:
------------------------------------------------------------------------
[2012-06-27 16:03:00] oxygenus at gmail dot com
var_export should receive a third param with a flag to detect recursivness and
set
NULL [or some special value such as an instance of an object of class
RecursiveError].
------------------------------------------------------------------------
[2012-03-28 05:48:38] jodybrabec at gmail dot com
WORKAROUND:
ob_start();
var_dump($GLOBALS);
$dataDump = ob_get_clean();
------------------------------------------------------------------------
[2011-03-26 15:21:12] ricki at rocker dot com
I don't believe this is a bug as the purposes of var_dump and var_export are
entirely different:
var_dump - simply dumps a readable form
var_export - exports valid PHP! This code is actually usable within an
application.
var_dump therefore can "manage" the recursive nature of global by simply doing
the following in the output
&array(15) {
["GLOBALS"]=>
*RECURSION*
var_export on the other hand clearly can't take the same approach to recursion
if the generated PHP output is to work as intended by the application designer.
- it can only (and should only) fail.
hope this is useful to someone.
------------------------------------------------------------------------
[2010-10-28 20:49:29] hendy at soluvas dot com
This bug is VALID!
The following code works:
var_dump($GLOBALS);
Therefore the dumping algorithm is inconsistent. var_export() should just use
the same algorithm as var_dump().
------------------------------------------------------------------------
[2010-06-27 05:55:26] jdickey at seven-sigma dot com
Derick, I'd suggest that that "expected behavior" itself is a design flaw in
the
PHP interpreter. The solutions I can think of right off would be ugly, granted
(special-case check for global-variable accessor to detect whether it's
attempting
to recurse as an effect of debug_backtrace() and, if so, throw an exception
that
can then be caught by d_bt); I find it really hard to believe that such a
heavily-
used software platform with such a large, competent company and community
behind
it can't come up with a better solution.
Marking this bug as 'bogus' merely insults your developer customers and
encourages
them to go find a real language instead.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=30471
--
Edit this bug report at https://bugs.php.net/bug.php?id=30471&edit=1