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

Why does the gettype() say it's a double but var_dump() says float?

Why does the gettype() say it's a double but var_dump() says float? $number = 1234567890123456789; echo "Number: {$number} is a ". gettype($number) . "\n"; var_dump($number); Response: Number: 1.23456789012E+18 is a double …
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
6
votes
4 answers

php var_dump equivelant or print_r

since I am using json, and ajax it's annoting I cn't pass the value on a valid json. is there away to just return the value of var dump without it echo,being output to the browser. e.g. $data = 'my_data'; get_var_dump($data);//not real func //should…
Val
  • 17,336
  • 23
  • 95
  • 144
6
votes
1 answer

Symfony 4: Var-dumper not working properly

I tried to use the wonderful dump function from the var-dumper bundle in symfony 4 and for some reason I get the following error: Failed to start the session because headers have already been sent by…
iiirxs
  • 4,493
  • 2
  • 20
  • 35
6
votes
4 answers

PHP session index undefined after header redirection?

I have struggled with this for hours but I can't get it to work. When I do a redirection to another PHP page, all my session variables are null. I am on xampp server. session.php
Matt Dathew
  • 135
  • 1
  • 12
6
votes
1 answer

var_dump of PDOStatement Object is not showing returned data

I'm trying to see the structure of the PDOStatement object returned by my query: $sql="SELECT co.CompanyId, co.Name, co.Address, co.City, co.State, ctry.NameEnglish, co.PostalCode FROM company AS co LEFT JOIN country AS ctry ON ctry.CountryId =…
Jonathan M
  • 17,145
  • 9
  • 58
  • 91
5
votes
1 answer

Why var_dump does not show null bytes?

I had 2 cases where null bytes \0 are being appended to my data. 1.Casting object to an array class myClass { private $var; function __construct() {} } $myObject = (array) new myClass(); var_dump(array_map("addslashes",…
user2917245
5
votes
1 answer

Why would var_dump return a bigger value than the string length?

I am working on getting some song lyrics using an API, and converting the lyrics string into an array of words. I am getting some unusual behaviors in preg_replace function. When I did some debugging using var_dump, I see that var_dump returns a…
Baykal
  • 569
  • 2
  • 10
  • 15
5
votes
4 answers

Pretty dump variable/object in Symfony 2.*?

When developing stuff I need to output the state of some instance in order to inspect it. While using CakePHP I always had a debug() function which does some kind of var_dump inside a
 html element, so the content is readable.
Is something…
Michael
  • 4,786
  • 11
  • 45
  • 68
5
votes
6 answers

How to create an array from output of var_dump in PHP?

How can I parse the output of var_dump in PHP to create an array?
omg
  • 136,412
  • 142
  • 288
  • 348
4
votes
7 answers

Why does var_dump(array) result in a 500 error in Magento?

I'm trying to see what is inside all the objects of the Magento system, but when I try to var_dump the $_links variable (containing all information needed for rendering the links in the header of every page) from inside the top links template, my…
pancake
  • 1,923
  • 2
  • 21
  • 42
4
votes
1 answer

xdebug var_dump function colors

I have installed xdebug on my computer with windows and it works fine by default - traces are colorfull and pretty but on another computer with ubuntu 10.10 its colourless and without any formatting. I tryed fill xdebug formatting parameters in…
Dmytro
  • 2,200
  • 3
  • 20
  • 32
4
votes
2 answers

When I debug php with var_dump variable it always outputs file path at the beginning?

I am using Ubuntu with PHP 7. PHP 7.0.5-3+donate.sury.org~xenial+1 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend…
Shi Falei
  • 51
  • 4
4
votes
5 answers

dump returned values as expanded array in laravel

I am using dump($value) function. I have an associative array with lots of entries in it. I need to see the values right away without having to click the expansion button when dumped. I can use var_dump() to see it right away but I like it more…
kriscondev
  • 765
  • 7
  • 21
4
votes
6 answers

How to get instance ID with PHP

I'm looking for a way to get the instance ID of a given object / resource with PHP, the same way var_dump() does: var_dump(curl_init()); // resource #1 of type curl var_dump(curl_init()); // resource #2 of type curl How can I get the instance count…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
4
votes
1 answer

var_dump seems to cause looping/ trial until timeout

I have the following files: utils.php where arrayForJSON is defined getLikes.php: include '../utils.php'; if($user_id) { try { if(is_null($likes)) $likes = idx($facebook->api('/me/likes'), 'data', array()); …
Mihai Bujanca
  • 4,089
  • 10
  • 43
  • 84
1 2
3
22 23