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
10
votes
3 answers

PHP - non-recursive var_dump?

When dealing with certain PHP objects, it's possible to do a var_dump() and PHP prints values to the screen that go on and on and on until the PHP memory limit is reached I assume. An example of this is dumping a Simple HTML DOM object. I assume…
Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
10
votes
2 answers

Why does var_dump show filename and line number?

Just recently var_dump() in PHP (currently using 5.6.23) started to print out the filename as well as the line number before actually dumping my variable. I'm not aware of any major changes on the server, so I was wondering why this happens, also…
Select0r
  • 12,234
  • 11
  • 45
  • 68
10
votes
1 answer

Question about var_dump output

When I var_dump an object, the output looks like this: object(XCTemplate)#2477 (4) { ["id"]=> string(1) "1" ["attributes"]=> array(0) { } ["db_table_name"]=> string(14) "template_names" ["cache"]=> array(0) { } } XCTemplate is…
Daniel
  • 4,949
  • 4
  • 34
  • 50
10
votes
4 answers

Looking for easy way to analyze var_dump (PHP) on large objects

I know (PHP's) var_dump is supposed to be "human readable" and all, but analyzing large objects is just a pain in the neck. I am struggling to make sense of a few of the large objects that are being passed around in a script that we are running. (I…
shaune
  • 2,510
  • 1
  • 31
  • 36
9
votes
3 answers

How can I recursively print the contents of a variable, including both the data and object attributes?

str() and repr() can be used to print the contents of a variable in python. But the contents of a variable may be quite complex. The pprint library, reported as the php var_dump() equivalent, works nicely for displaying just data in an easy to read…
jozxyqk
  • 16,424
  • 12
  • 91
  • 180
9
votes
3 answers

Alternative var_dump for PHP that allows limiting depth of nested arrays

I try to use var_dump on command line with phpsh in order to get debugging information about some variable. But the variable contains a very deeply nested data structure. Therefore, using the default var_dump outputs too much information. I want to…
Mert Nuhoglu
  • 9,695
  • 16
  • 79
  • 117
9
votes
5 answers

Xdebug does not work with var_dump()

I'm not sure why, but xdebug does not highlight var_dump(). But config seems to be fine. Have no idea why... Any suggestions? This is my phpinfo(); http://pastebin.com/A45dqnWN plus even xdebug_var_dump() doesn't highlight anything. It works, but…
dlitsman
  • 271
  • 2
  • 9
8
votes
3 answers

PHP: Colors in var_dump (Ubuntu)

I'd like to see the colors and formatting that can come with var_dump. In my php.ini html_errors is set to On. This is confirmed by phpinfo(). My PHP version is 5.3.3 on Ubuntu 10.10. Anybody an idea?
user585936
8
votes
6 answers

Colored var_dump() and errors

How can I set style to var_dump() function and PHP errors style, like on the next image? At the moment I have next view of var_dump() (with
var_dump(...)
, without it will be all in one line) and just plain text for errors. I searched…
kxc
  • 1,357
  • 2
  • 16
  • 39
8
votes
4 answers

How do I properly use print_r or var_dump?

I use the following snippet quite often when I am debugging: echo "
" . var_dump($var) . "
"; And I find I usually get a nice readable output. But sometimes I just don't. I'm particularly vexed at the moment by this…
Michael Corvis
  • 83
  • 1
  • 1
  • 4
7
votes
1 answer

Unexpected observation: var_dump() of an array is flagging referenced elements... since when?

I've just been running some simple debug tests against arrays, and noticed that when I do a var_dump() of an array, the output is flagging any element in the array that is referenced by another variable. As a simple experiment, I ran the following…
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
7
votes
1 answer

Why does var_dump display the file path?

I'm having some problems with var_dump. This is my code: $rezultat = 5 < 2; $rezultat1 = 5 > 2; var_dump($rezultat); echo $rezultat1; And this outputs: C:\wamp\www\djole-php\test.php:5:boolean false 1 As you can see, var_dump displays the whole…
Karadjordje
  • 315
  • 3
  • 13
7
votes
4 answers

Detecting simpleXml array property

I think I'm missing something really obvious here, but can someone explain to me why I'm getting the output I am and not the output I expect on the following var dumps: Here's the original xml: 3
Stu
  • 4,160
  • 24
  • 43
7
votes
3 answers

Printing more than one array using print_r or any other function in php

I need to print contents of multiple arrays in my code. Eg function performOp($n, $inputArr, $workArr) { printf("Entered function, value of n is %d", $n); print_r($inputArr); print_r($workArr); $width =0; } Now,…
user_stackoverflow
  • 734
  • 2
  • 10
  • 18
6
votes
3 answers

PHP refuses to output data from var_dump, print, etc

I'm running a WAMP server at the moment, and have been spending the past 30 minutes trying to figure out how and why my project won't output any PHP data specified. At first, I thought that it was because I had an .htaccess file which…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
1
2
3
22 23