PHP
  Home arrow PHP arrow Page 2 - Working with the X-debug extension`s var_dump() 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

Working with the X-debug extension`s var_dump() function
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-02-17


    Table of Contents:
  • Working with the X-debug extension`s var_dump() function
  • Review: the xdebug_call_function() method
  • Using the enhanced version of the var_dump() PHP function
  • Retrieving information about a PHP object with the var_dump() 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


    Working with the X-debug extension`s var_dump() function - Review: the xdebug_call_function() method
    ( Page 2 of 4 )

    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){

    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'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:


    try{

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

    echo $user->getFunction();

     

    /* displays the following

    Called from function {main}

    */

    }

    catch(Exception $e){

    echo $e->getMessage();

    exit();

    }


    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
     

       

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek