Reputation: 2821
I need a function like var_dump($object)
in php
The problem is that the Var_dump function print every thing on the screen and
I just need the answer in a variable.
I mean sth like $variable=var_dump($object);
And I dont want to see anything on screen!
thanks
Upvotes: 3
Views: 2107
Reputation: 2722
Sometimes json_encode() can be handy:
$variable = json_export($data);
Or
$variable = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
Upvotes: 0
Reputation: 4860
U can also use the output-control functions
ob_start();
var_dump($object);
$description = ob_get_clean();
Upvotes: 2