When I echo var_dump($_variable), I get one long, wrapping line with all varable's and values like
["kt_login_user"]=> string(8) "teacher1" ["kt_login_id"]=> string(3) "973" ["kt_campusID"]=> string(4) "9088" ["kt_positionID"]=> string(1) "5"
Is there a way I can make each value display on its own line for ease of reading? Something like this:
["kt_login_user"]=> string(8) "teacher1"
["kt_login_id"]=> string(3) "973"
["kt_campusID"]=> string(4) "9088"
["kt_positionID"]=> string(1) "5"
For devs needing something that works in the view source and the CLI, especially useful when debugging unit tests.
Yields:
If you got XDebug installed, you can use it's
var_dump
replacement. Quoting:You will likely want to tweak a few of the following settings:
But keep in mind that XDebug will significantly slow down your code, even when it's just loaded. It's not advisable to run in on production servers. But hey, you are not var_dumping on production servers anyway, are you?
I did a similar solution. I've created a snippet to replace 'vardump' with this:
Ps: I'm repeating the data with the last var_dump to get the filename and line
So this: Became this:
Let me know if this will help you.
Use output buffers: http://php.net/manual/de/function.ob-start.php
Yet another option would be to use Output buffering and convert all the newlines in the dump to
<br>
elements, e.g.For me the right answer was
Since
var_dump($var)
andvar_export($var)
do not return a string, you have to usevar_export($var, true)
to forcevar_export
to return the result as a value.Yes, try wrapping it with
<pre>
, e.g.: