It’s often useful to use var_dump() while debugging but sometimes you aren’t ready to output to the screen yet. Here’s how to store PHP var_dump() in a variable:
nice post man thanks
Very helpful. Thanks for posting this.
very useful in CLI usage, thanks
var_export($var, true); is a better option.
really useful, this feature should however be integrated in the var_dump() function
var_dump($var, true); would be great
Thx so much , saved my life
I found this super useful. I didn’t realize that var_dump printed directly to the screen. We were using it in unit tests and it wasn’t showing up. This method fixes that.