NYCPHP Meetup

NYPHP.org

[nycphp-talk] who's calling me?

Ben Sgro (ProjectSkyLine) ben at projectskyline.com
Mon Jul 23 19:39:32 EDT 2007


Hello, 

On that note, let me show you some code I use for debugging:
Might be helpful, as it shows the file name.

    /*! @function   Backtrace
        @discussion This is called for fatal errors. Takes a backtrace and
            located the offending function (highest index) and then writes
            its contents to the error log file.
            
        @result Writes a detailed backtrace to the error log file.
    */
    function Backtrace( )
    {
        $btSet  = debug_backtrace( );
        $iValue = 1; /* [0] is the traceback for the Error:: *///sizeof($btSet) - 1;
        $eSet   = $btSet[$iValue];
        
        $errorStr = "\ndate: " . date('r')
                  . "\nfile: " . $eSet['file']
                  . "\nline: " . $eSet['line']
                  . "\nfunction: " . @$eSet['class'] . '::' . $eSet['function']
                  . "\nargs: ";

        /* Build a list of the functions arguments. */
        while(list($argIndex, $argStr) = each($eSet['args']))
        {
            $errorStr .= "[${argIndex}]$argStr ";
        }
        $this->builtMessage = $errorStr;
    }

- Ben

Ben Sgro, Chief Engineer
ProjectSkyLine - Defining New Horizons
+1 718.487.9368 (N.Y. Office)

Our company: www.projectskyline.com
Our products: www.project-contact.com

This e-mail is confidential information intended only for the use of the individual to whom it is addressed.
  ----- Original Message ----- 
  From: Tom Sartain 
  To: NYPHP Talk 
  Sent: Monday, July 23, 2007 7:28 PM
  Subject: Re: [nycphp-talk] who's calling me?


  Check out debug_backtrace. http://us2.php.net/debug_backtrace
  There's plenty of helpful info in the array it returns.


  On 7/23/07, Rahmin Pavlovic <rahmin at insite-out.com> wrote:
    Say I'm an include.  Say several templates include me into what will become
    a single web page.  How can I tell which template is calling me?


    _______________________________________________
    New York PHP Community Talk Mailing List 
    http://lists.nyphp.org/mailman/listinfo/talk

    NYPHPCon 2006 Presentations Online
    http://www.nyphpcon.com

    Show Your Participation in New York PHP
    http://www.nyphp.org/show_participation.php





------------------------------------------------------------------------------


  _______________________________________________
  New York PHP Community Talk Mailing List
  http://lists.nyphp.org/mailman/listinfo/talk

  NYPHPCon 2006 Presentations Online
  http://www.nyphpcon.com

  Show Your Participation in New York PHP
  http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070723/38a7bad9/attachment.html>


More information about the talk mailing list