Search code examples
php-5.3var-dump

PHP 5.3.10: var_dump does not print readable results as it used to be


After I have upgraded my localhost wamp server to php 5.3.10, the var_dump does not print results that are as readable/pretty as they used to be.

$obj = (object) array('qualitypoint', 'technologies', 'India');
var_dump($obj);

object(stdClass)#2 (3) { [0]=> string(12) "qualitypoint" [1]=> string(12) "technologies" [2]=> string(5) "India" }

As you can see that everything now is cramp into one line.

It used to print something like this below though,

object(stdClass)#1 (3) {
 [0]=> string(12) "qualitypoint"
 [1]=> string(12) "technologies"
 [2]=> string(5) "India"
}

How can I make var_dump to return a readable formatted result?


Solution

  • object(stdClass)#2 (3) { [0]=> string(12) "qualitypoint" [1]=> string(12) "technologies" [2]=> string(5) "India" }
    

    Is normal PHP output for this code:

    $obj = (object) array('qualitypoint', 'technologies', 'India');
    var_dump($obj);
    

    For more readable format You probably used Xdebug extension for PHP. Check You PHP extensions directory (PHP directory/ext/ on Windows).

    If there is not file with name like this:

    php_xdebug-X.X.X-X.X-vcX.dll

    Download one for You PHP version

    Put it in extensions directory add to PHP configuration (php.ini file) bellow other PHP extensions.

    Example:

    zend_extension=PHP_EXTENSIONS_ABSOLUTE_PATH\php_xdebug-2.1.2-5.3-vc9.dll

    Restart Apache and var_dump() output will be formatted like this:

    object(stdClass)[1]
      string 'qualitypoint' (length=12)
      string 'technologies' (length=12)
      string 'India' (length=5)