php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #6238 var_dump() param for deactivating reference following
Submitted: 2000-08-18 11:06 UTC Modified: 2004-01-17 09:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: waldschrott@php.net Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.0 Latest CVS (18/08/2000) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: waldschrott@php.net
New email:
PHP Version: OS:

 

 [2000-08-18 11:06 UTC] waldschrott@php.net
It would be very, very helpful if we could *disable*
reference resolution in var_dump() output, working with
circular references and then trying a var_dump() on any
involved object results in a really big mess, I killed my
browser after it grew up to 250Megs.
It?s really handy that var_dump() recognizes if it?s a
variable or not (by prepending &) and I can imagine that
profit supercedes the efforts to implement this greatly.

that applies to  print_r() and similar functions too

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-18 11:11 UTC] waldschrott@php.net
of course, deactivation with an optinal parameter,
like
var_dump($megaobject,TRUE);
 [2000-08-18 11:27 UTC] waldschrott@php.net
hah, just found out that get_object_vars() doesn?t work with circular references too... very bad

summary, using circular references very much makes scripts very hard (impossible) to debug because of this bug.
You?ll have to kill all circular references to be able to debug objects, depending on number of CRs it?s perhaps no trivial task cos there?s no function like get_object_references() to be able to kill them

so var_dump() supports multiple variables, then perhaps
svar_dump() for safe var dump or any other name

maybe get_object_vars() can get this second SAFETY parameter....
 [2000-08-18 11:29 UTC] waldschrott@php.net
maybe I was too fast... get_object_vars() of course works with circular references, but again var_dump()ing them does not work, it has nothing to do with get_object_vars()...
 [2000-08-18 12:40 UTC] waldschrott@php.net
If someone takes the task designing a new svar_dump() or similar (custom_dump()), we could add two parameters.
param 1) steps, how many steps to resolve, unset=all (as it is currently),1=one level, 2=two levels etc.
we would catch the issue that var_dump() produces never ending output with that too, but It?ll be even better to have both, thus...
param 2) do not resolve references

That?s significant added value and could make debugging a lot easier....

example step=2,no_resolve=TRUE
object(a)(3) { ["a"]=> int(0) ["b"]=> array(3) {
  ["a"]=> array(24)
  ["b"]=> array(14) 
  ["a"]=> array(7) } ["c"]=> &object(circular) (20) }
// "c" does not get expanded, because of no_resolve...

example step=1,no_resolve=FALSE
object(a)(3) { ["a"] int(0) ["b"]=> array(3) ["c"]=> &object(circular) (1) { ["x"] => &object(a) (3) } }

example step=0,no_resolve=TRUE 
// no resolve doesn?t matter here
object(a)(3) { ["a"] int(0) ["b"]=> array(3) ["c"]=> &object(circular) (1) }

Please comment, If anything thinks that?s a good/bad idea...
 [2004-01-17 09:35 UTC] andrey@php.net
var_dump() cannot be extended in such a way since it currently dumps the every value passed to it. Thefefore it will break BC. var_dump() currently works better with circular references than before - does not crash.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC