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
2
votes
2 answers

Can't make dump() work in Symfony 4.2 toolbar

I am new to Stack Overflow and programming and I have a bad english, so sorry in advance if I don't ask things correctly. I am learning how to use Symfony and I can't get the dump() function to work properly. I followed the instruction at…
myst
  • 21
  • 3
2
votes
3 answers

var_dump displays text, but echo does not

I have an array called $worker the array consists of only strings, each of which has multiple lines. if I do var_dump($worker); it displays all the information, but do for($i=0,$size=sizeof($worker);$i<$size;++$i) { echo $worker[i]; } I end…
motsu35
  • 21
  • 2
  • 5
2
votes
1 answer

MSSQL datetime object won't echo out the correct date if i remove its var_dump

I'm trying to create a simple table displaying data from June 2019, however i'm having trouble getting the MSSQL datetime row to echo out correctly whenever i remove my var_dump line. So with the var_dump i get the correct dates but without all my…
Chris
  • 35
  • 4
2
votes
1 answer

Why I can only reach my date object when I dump() it before using it?

Why I can only reach my date object when I dump() it before using it? Here is my function: public function checkSubscriptionEndDate($user){ $subscriptionEndDate = $user->getSubscriptionEndDate(); dump($subscriptionEndDate); …
Kr1
  • 1,269
  • 2
  • 24
  • 56
2
votes
0 answers

In vbs equivalent to php vardump?

I want to be able to dump the contents (all variables and types) of my variable to something I can see it in. ie( msgbox )
Tolure
  • 859
  • 1
  • 14
  • 34
2
votes
1 answer

var_dump output using foreach reference loop

I am using a foreach loop with referencing, ie: foreach($elements as &$item) Now when I use var_dump($elements); after the foreach(), the last element always has an & character prepended to it's variable-type (&string, &array, &boolean,…
xorinzor
  • 6,140
  • 10
  • 40
  • 70
2
votes
0 answers

PHP times out and Firefox crashes due to adding var_dump to code

I try to rewrite this Python code in PHP. Currently I'm debugging it and strange thing happens: when I add var_dump in the piece of code, where Apache2 error log reports: HP Fatal error: Call to a member function setext() on a non-object then…
r34
  • 320
  • 2
  • 12
2
votes
1 answer

Unable to access associative array values

I have two config files. The first, which is called configs.php contains an array with some values: $welcomeConfigs = [ "title" => "welcome", "description" => "a description" ]; The second file includes the configs.php one and use the its array…
ctrlmaniac
  • 404
  • 4
  • 13
  • 28
2
votes
1 answer

Is there an equivalent of var_dump for methods in PHP?

I'm working on some legacy code and I need to get some information from an object. The price, for example. The price could be stored in a variable or it could be retrieved via a method. I don't yet know, only that it exists within the object. I can…
piersb
  • 609
  • 9
  • 22
2
votes
2 answers
2
votes
2 answers

PHP display a readable array

I see manual of php.net and see sortie of examples, when use var_dump and others commands for see examples. All examples sort with pre style. But on my own server I see same examples on only one line var_dump($a); On manual see-> array(3)…
abkrim
  • 3,512
  • 7
  • 43
  • 69
2
votes
2 answers

Visually same string gives different var_dumps in php

UPDATE: Anwer is here PHP unserialize fails with non-encoded characters? I'm trying to match objects with in_array. This works fine except for the object with this string as a property. Visually they are the same, but when I do a var_dump PHP sees…
Marc van Nieuwenhuijzen
  • 1,637
  • 1
  • 14
  • 22
2
votes
1 answer

PHP DateTime Class Producing Unexpected Results

I have been getting used to the DateTime Class and am getting unexpected results from the code below: '; $newDate = date("Y-m-d H:i:s",strtotime("$now + 1 years")); $converted =…
underflow
  • 483
  • 3
  • 15
2
votes
1 answer

echo and (var_dump or print_r) showing completely different things on laravel object

I have this code in laravel: $languages = $languages->orderBy($sort_by,$sort_dir) ->take($limit) ->paginate($limit); echo $languages->getCollection(); echo $languages->links(); These lines echo something but if I…
ionescho
  • 1,360
  • 2
  • 17
  • 31
2
votes
3 answers

How to convert output of var_dump to array or variable?

I am trying to take difference of two time. I have used diff function for that and now I want to transfer output of var_dump to array or variable so that I am able to print remaining time. My code is written below. How to retrieve below output to…