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

Review: the xdebug_call_function() method - 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.

  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



Before I start teaching you how to use the "var_dump()" function included with the X-debug extension, I will reintroduce the hands-on example created in the preceding article of this series. It demonstrated how to track function calls via the "xdebug_call_function()" method.

Put in a simple way, the example in question made use of a sample "User" class, whose signature looked like this:

(example on using the 'xdebug_call_function()' function)

class User{

private $firstName;

private $lastName;

private $email;

public function __construct($firstName,$lastName,$email){


throw new Exception('Invalid parameter First Name.');



throw new Exception('Invalid parameter Last Name.');



throw new Exception('Invalid parameter Email.');






// get first name

public function getFirstName(){

return $this->firstName;


// get last name

public function getLastName(){

return $this->lastName;


// get email

public function getEmail(){

return $this->email;


// get the function that was called

public function getFunction(){

return 'Called from function '.xdebug_call_function();



As you'll probably recall, the above "User" class implemented a basic method called "getFunction()," which utilized the "xdebug_call_function()" function to return to client code the name of the function that originally called the method in question.

To help you understand this concept more clearly, below there's a short code sample that demonstrates the functionality of the "xdebug_call_function()" function. Here it is:


$user=new User('Alejandro','Gervasio','alejandro@domain.com');

echo $user->getFunction();


/* displays the following

Called from function {main}



catch(Exception $e){

echo $e->getMessage();



Definitely, the previous script is very easy to follow. It shows that the pertinent "getFunction()" method that belongs to the "User" class was called originally from the "main" function in C (remember that PHP was built with this medium-level programming language). Simple and pretty illustrative, right?

Now that you've recalled how to use the "xdebug_call_function()" function of the X-debug library to keep track of the different function calls performed during the execution of a PHP script, it's time to explore a few other features provided by this debugging library.

In the following section I'll be explaining how to use the enhanced version of the native "var_dump()" PHP function for retrieving useful and abundant information on a specified variable.

To see how this function works you'll have to click on the link that appears below and keep reading.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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


Dev Shed Tutorial Topics: