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.
blog comments powered by Disqus |
|
|
|
|
|
|
|