var-dump
Making PHP var_dump() values display one line per value
Yes, try wrapping it with <pre>, e.g.: echo ‘<pre>’ , var_dump($variable) , ‘</pre>’;
Convert var_dump of array back to array variable
var_export or serialize is what you’re looking for. var_export will render a PHP parsable array syntax, and serialize will render a non-human readable but reversible “array to string” conversion… Edit Alright, for the challenge: Basically, I convert the output into a serialized string (and then unserialize it). I don’t claim this to be perfect, but … Read more
How to see full content of long strings with var_dump() in PHP
You are using xdebug, which overloads the default var_dump() to give you prettier and more configurable output. By default, it also limits how much information is displayed at one time. To get more output, you should change some settings. Add this to the top of your script: ini_set(“xdebug.var_display_max_children”, ‘-1’); ini_set(“xdebug.var_display_max_data”, ‘-1’); ini_set(“xdebug.var_display_max_depth”, ‘-1’); From the … Read more
Make var_dump look pretty [duplicate]
I really love var_export(). If you like copy/paste-able code, try: echo ‘<pre>’ . var_export($data, true) . ‘</pre>’; Or even something like this for color syntax highlighting: highlight_string(“<?php\n\$data =\n” . var_export($data, true) . “;\n?>”); Reusable function: function highlight_array($array, $name=”var”) { highlight_string(“<?php\n\$$name =\n” . var_export($array, true) . “;\n?>”); } You can do the same with print_r(). For … Read more
What is the JavaScript equivalent of var_dump or print_r in PHP? [duplicate]
Most modern browsers have a console in their developer tools, useful for this sort of debugging. console.log(myvar); Then you will get a nicely mapped out interface of the object/whatever in the console. Check out the console documentation for more details.
How can I capture the result of var_dump to a string?
Try var_export You may want to check out var_export — while it doesn’t provide the same output as var_dump it does provide a second $return parameter which will cause it to return its output rather than print it: $debug = var_export($my_var, true); Why? I prefer this one-liner to using ob_start and ob_get_clean(). I also find … Read more