PHP
  Home arrow PHP arrow Page 3 - Using the Xdebug Extension`s xdebug_call_function() Function
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Using the Xdebug Extension`s xdebug_call_function() Function
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-02-09


    Table of Contents:
  • Using the Xdebug Extension`s xdebug_call_function() Function
  • Review: the xdebug_call_file() and xdebug_call_line() functions
  • Using the xdebug_call_function() function
  • Testing the xdebug_call_function()

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using the Xdebug Extension`s xdebug_call_function() Function - Using the xdebug_call_function() function
    ( Page 3 of 4 )

    Quite often when debugging a PHP application, it's necessary to find out from which function a method or statement has been called. To accomplish this task with minor efforts, the Xdebug extension provides the "xdebug_call_function()" function (the name isn't redundant, trust me).

    As usual, to demonstrate how this function can be used in a concrete situation, I'm going to appeal to the functionality of the "User" sample class that was built in the first article. However, in this case, this class will implement a new method, called "getFunction()," which will show you how to work with the "xdebug_call_function()" function.

    Here's the modified signature of this class, so pay attention to the way it functions:


    class User{

    private $firstName;

    private $lastName;

    private $email;

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

    if(!$firstName){

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

    }

    if(!$lastName){

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

    }

    if(!$email){

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

    }

    $this->firstName=$firstName;

    $this->lastName=$lastName;

    $this->email=$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 can see, the above "User" class now declares and implements a new method called "getFunction()" that internally uses the "xdebug_call_function()" to return to client code the name of the function that invoked the method.

    As with the other functions discussed in the preceding article, this one can also be used when debugging procedural PHP programs, so it's clear to see that there's plenty of room for experimenting with this brand new function.

    Now, and returning to the implementation of the above "getFunction()" method, it should be extremely easy to grasp for you, even though it still hasn't been used in the context of a practical example. Don't worry; in the following section I will write a short code sample that will help to demonstrate the actual functionality of the "xdebug_call_function()."

    To learn how this new example will be developed, please click on the link below and read the next few lines.



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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek