Is there a straightforward way in PHP to get an arbitrary complex value into a string without triggering recursion limits? For example, passing an hugely nested object and specifying I want only 2 levels deep.
What I want to avoid is getting an error on var_export or var_dump, even if that means that I get less accurate output.
Thanks!
Clarification: I want to use the string for logging usage, so debuggers are not applicable.
Maybe having a super class looking like this:
Then you’re able to call
var_dump( $my_dumpable_obj->varDump() );when wanting to dump an an object extending Dumpable. If your server supports php 5.4 it might be better to use this functions in a Trait instead.