Home arrow PHP arrow Page 3 - Working with the X-debug extension`s var_dump() function

Using the enhanced version of the var_dump() PHP function - PHP

If you’re a PHP developer who’s searching for an approachable guide to using the most relevant functions that come bundled with the X-debug extension, then look no further. Welcome to the third article of a series on debugging in PHP with the X-debug extension. Comprised of seven tutorials, this series teaches you how to utilize the features that come with the X-debug library to debug your own PHP applications.

TABLE OF CONTENTS:
  1. Working with the X-debug extension`s var_dump() function
  2. Review: the xdebug_call_function() method
  3. Using the enhanced version of the var_dump() PHP function
  4. Retrieving information about a PHP object with the var_dump() function
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
February 17, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

As I mentioned in the section that you just read, the X-debug extension comes equipped with an enhanced version of the popular "var_dump()" native PHP function, which you may have used hundreds of times already when debugging your own PHP programs.

The best way to grasp how this improved "var_dump()" function works is by means of a concrete example. With that idea in mind, below I set up for you a basic code sample that shows the real capabilities of this function. Have a look at it, please:


$data=array('string'=>'This is a string','integer'=>1,'float'=>0.123456,'array'=>array(1,2,3,4,5,5));

var_dump($data);


/* displays the following

array

'string' => string 'This is a string' (length=16)

'integer' => int 1

'float' => float 0.123456

'array' =>

array

0 => int 1

1 => int 2

2 => int 3

3 => int 4

4 => int 5

5 => int 5

*/


Despite the simplicity of the above example, it's pretty useful for demonstrating the completeness of the information returned by the "var_dump()" function when it's fed an array composed of different elements. In this particular case, the function not only is capable of retrieving the values assigned to each element of the $data array, but it returns the corresponding indexes, the length of the string elements (when applicable), and the type of data stored in each of them.

As you can see, this enhanced version of the "var_dump()" PHP function permits you to obtain valuable information about a particular variable. This can be really useful for debugging several applications in depth. 

So far, so good. By now you've grasped how the "var_dump()" function does its business, so it's time to finish this tutorial by coding a slightly more complex example. It will be aimed at illustrating how this function can be used for returning complete information about a specified PHP object.

This topic will be covered in detail in the following section. Therefore, please read the next few lines.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: