Reputation: 447
I use var_dump to debug some php scripts locally where I have php 5.6 installed and it formats beautifully on all browsers.
array (size=1)
0 =>
object(WP_Post)[1173]
public 'ID' => int 33
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2018-01-11 17:26:22' (length=19)
public 'post_date_gmt' => string '2018-01-11 23:26:22'(length=19)
When I upload the same file to a production box with php 7, the output is there, but the format is gone! any reason or clue why this is happening?
array(1) { [0]=> object(stdClass)#1162 (3) { ["ID"]=> string(2) "61" ["post_title"]=> str
Upvotes: 1
Views: 2109
Reputation: 447
XDebug was the main reason! Since I am using Amazon Linux with PHP7, XDebug is not installed by default, so as soon as you install XDebug, var_dump outputs the readable version of the text.
Upvotes: -1
Reputation: 15131
That "beautiful" format is probably because of Xdebug.
But, you can always use <pre>
tags.
<?php
echo "<pre>";
var_dump($var);
echo "</pre>";
It's not the same, but will help.
And remember, Xdebug shouldn't be installed/activated on production environment.
Upvotes: 5