Home arrow PHP arrow Page 4 - Using the Xdebug Extension`s xdebug_call_function() Function

Testing the xdebug_call_function() - PHP

Among the numerous PHP debugging libraries available these days on the web, there’s one that offers easy installation and a flat learning curve, along with powerful features that permit you to debug PHP applications with minor hassles. I'm talking about the Xdebug extension, of course, and in this second part of a seven-part series you'll learn how to use its xdebug_call_function () function.

TABLE OF CONTENTS:
  1. Using the Xdebug Extension`s xdebug_call_function() Function
  2. Review: the xdebug_call_file() and xdebug_call_line() functions
  3. Using the xdebug_call_function() function
  4. Testing the xdebug_call_function()
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
February 09, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

To demonstrate how useful the "xdebug_call_function()" can be for debugging purposes, I'm going to build a simple script which will make use of the "User" class that you saw in the previous section. In this case, the script simply will be tasked with creating a new instance of this class, and then with calling its "getFunction()" method.

The result of this operation can be seen in the code sample below:


try{

$user=new User('John','Doe','john@domain.com');

echo $user->getFunction();

 

/* displays the following

Called from function {main}

*/

}

catch(Exception $e){

echo $e->getMessage();

exit();

}


Well, if you were expecting an output of one hundred lines, then probably you'll be a bit disappointed with the result produced by the above example. However, it's pretty illustrative, since it shows in a nutshell how the "xdebug_call_function()" really works. In this particular example, the function has been wrapped within a class method, so it returns the name of the function from which it was actually called, that is the C "main" function.

With this basic example, it's clear to see how deeply the xdebug_call_function()" can dig when it comes to determining from which function a method or statement has been invoked. Simple and effective, right?

And finally, as usual with many of my articles on PHP development, feel free to tweak all of the code samples shown in this tutorial to give you some practice in using the "xdebug_call_function()" function provided by the Xdebug extension. You'll have a good time doing this, guaranteed!

Final thoughts

In this second installment of the series, I walked you through using the "xdebug_call_function()" function, bundled with the X-debug extension, to keep track of the different functions calls triggered by a PHP script.

In the next part, I will explain how to use the enhanced version of the "var_dump()" PHP built-in function to retrieve detailed information about a specified variable. Now that you know the subject of the upcoming article, you won't want to miss it!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

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

 


Dev Shed Tutorial Topics: