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