Questions tagged [var-dump]

var_dump is a PHP function that dumps information about a variable.

var_dump is a PHP function that dumps information about a variable.

Examples

$a=array(1,2,3);
var_dump($a);
$b="hello so";
var_dump($b);

returns

array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
string(8) "hello so"

References

332 questions
673
votes
13 answers

How can I capture the result of var_dump to a string?

I'd like to capture the output of var_dump to a string. The PHP documentation says; As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a…
Mark Biek
  • 146,731
  • 54
  • 156
  • 201
321
votes
9 answers

What is the JavaScript equivalent of var_dump or print_r in PHP?

I would like to see the structure of object in JavaScript (for debugging). Is there anything similar to var_dump in PHP?
Adriana
  • 8,464
  • 13
  • 36
  • 37
207
votes
16 answers

Make var_dump look pretty

I have a simple $_GET[] query var set for showing testing data when pulling down queries from the DB.
Plummer
  • 6,522
  • 13
  • 47
  • 75
85
votes
14 answers

Making PHP var_dump() values display one line per value

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"…
user1320318
  • 889
  • 1
  • 6
  • 7
62
votes
4 answers

How to see full content of long strings with var_dump() in PHP

I have an array with some strings like $array = array("string1","string2","string3"); But those strings are very long, with a length of 2000+ sometimes. So when I do echo "
";
var_dump($array);
echo "
"; It shows me something like string…
Carlos2W
  • 2,024
  • 2
  • 16
  • 19
48
votes
7 answers

Convert var_dump of array back to array variable

I have never really thought about this until today, but after searching the web I didn't really find anything. Maybe I wasn't wording it right in the search. Given an array (of multiple dimensions or not): $data = array('this' => array('is' =>…
Chuck Burgess
  • 11,600
  • 5
  • 41
  • 74
36
votes
2 answers

json_encode() returns false

This is the first time I ever face, that var_dumping json_encode of an array resulting boolean value. I have an array that was resulted from unserialization. I var_dumped it and made sure that it is a valid array. The result is like below. This is…
M Rijalul Kahfi
  • 1,460
  • 3
  • 22
  • 42
35
votes
4 answers

save var_dump into text file

I have the php code for sql query
Yasser Abo Reida
  • 353
  • 1
  • 4
  • 8
28
votes
16 answers

How to write own DD() function same as laravel?

I used laravel for a long time but currently I work with wordpress. I loved using the laravel's DD() function. But in wordpress I can only use these, print_r(), var_dump(), var_export().... These all are just expand entire array or…
Shankar Thiyagaraajan
  • 1,705
  • 4
  • 28
  • 46
17
votes
1 answer

Does xdebug beautify var_dump?

According to this article, http://devzone.zend.com/article/2803, var_dump is supposed to beautify the outputs. I have installed xdebug on my local host with PHP Version 5.3.3-1ubuntu9.2. I have this in my php.ini outputs. This program makes use of…
shin
  • 31,901
  • 69
  • 184
  • 271
15
votes
7 answers

Human Readable JSON: aka Add spaces and breaks to json dump

Is there a "simple" script somewhere that will take a json data and format it to make it more readable? For example: // $response is a json encoded string. var_dump($response); The above outputs everything on one line. I'd like for it to be…
kylex
  • 14,178
  • 33
  • 114
  • 175
11
votes
6 answers

custom var_dump output for my class

is it possible to override var_dump output for a custom class? I want something like this: class MyClass{ public $foo; public $bar; //pseudo-code public function __dump($foo, $bar) { return 'Foo:$foo, bar:$bar'; …
amik
  • 5,613
  • 3
  • 37
  • 62
11
votes
12 answers

Sending "var_dump" to FireBug console

As you know var_dump() in addition to value show its data type and length. Is there any way to log its output to FireBug console? I tried FirePHP and FireLogger but both output only value of a variable (sometimes even incorrect variable value).
Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
11
votes
3 answers

cakephp log an array as var_dump

I need to jump into a server side code. It is used cakephp there. I would like to see a variable, I think it is a model, but I am not sure, let be a variable in or case. CakeLog::write('debug', 'myArray'.var_export($myArray) ); it will have the…
user529543
11
votes
8 answers

var_dump or print_r and html encoding

","","b","i","

hello

"); print_r ($x); echo "
"; var_dump ($x); outputs this in the html source! Array ( [0] => [1] => [2] => b [3] => i [4] =>

hello

)
array(5) { [0]=> …
Average Joe
  • 4,521
  • 9
  • 53
  • 81
1
2 3
22 23