Joomla! Discussion Forums



It is currently Thu Nov 26, 2009 6:46 am (All times are UTC )

 




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: PHP debugging
Posted: Fri Aug 22, 2008 2:13 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Nov 10, 2005 8:54 pm
Posts: 62
There was an awesome instructional page written by ianmac regarding debugging PHP code on Eclipse, but it appears to have disappeared. Is there a new URL for this page ianmac? Or did you take it down permanently. I hope not because it was a great resource and helped me out tremendously.

thanks!


Top
   
 
 Post subject: Re: PHP debugging
Posted: Fri Aug 22, 2008 7:47 pm 
Joomla! Virtuoso
Joomla! Virtuoso
Offline

Joined: Sat Nov 11, 2006 9:34 pm
Posts: 3781
Location: Hungary
Look at this article:
http://docs.joomla.org/Setting_up_your_ ... evelopment

_________________
Gergő Erdősi - Bug Squad Team Member, Joomla! 1.6 Release Team Member


Top
  E-mail  
 
 Post subject: Re: PHP debugging
Posted: Sat Aug 23, 2008 7:32 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Nov 10, 2005 8:54 pm
Posts: 62
Very nice. Thanks!


Top
   
 
 Post subject: Re: PHP debugging
Posted: Mon Aug 25, 2008 6:41 pm 
User avatar
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon Aug 25, 2008 6:17 pm
Posts: 4
Location: New Jersey
Just because I try to make this available to anyone who might care: you might get some mileage out of this snippet that makes PHP produce stack traces on errors and warnings, instead of useless final-location-only errors:
Code:
<?php
function process_error_backtrace($errno, $errstr, $errfile, $errline, $errcontext) {
    if(!(error_reporting() & $errno))
        return;
    switch($errno) {
    case E_WARNING      :
    case E_USER_WARNING :
    case E_STRICT       :
    case E_NOTICE       :
    case E_USER_NOTICE  :
        $type = 'warning';
        $fatal = false;
        break;
    default             :
        $type = 'fatal error';
        $fatal = true;
        break;
    }
    if(php_sapi_name() == 'cli') {
        echo 'Backtrace from ' . $type . ' \'' . $errstr . '\' at ' . $errfile . ' ' . $errline . ':' . "\n";
        foreach(array_reverse(debug_backtrace()) as $item)
            echo '  ' . (isset($item['file']) ? $item['file'] : '<unknown file>') . ' ' . (isset($item['line']) ? $item['line'] : '<unknown line>') . ' calling ' . $item['function'] . '()' . "\n";
    } else {
        echo '<p class="error_backtrace">' . "\n";
        echo '  Backtrace from ' . $type . ' \'' . $errstr . '\' at ' . $errfile . ' ' . $errline . ':' . "\n";
        echo '  <ol>' . "\n";
        foreach(array_reverse(debug_backtrace()) as $item)
            echo '    <li>' . (isset($item['file']) ? $item['file'] : '<unknown file>') . ' ' . (isset($item['line']) ? $item['line'] : '<unknown line>') . ' calling ' . $item['function'] . '()</li>' . "\n";
        echo '  </ol>' . "\n";
        echo '</p>' . "\n";
    }
    if($fatal)
        exit(1);
}

set_error_handler('process_error_backtrace');
?>

_________________
Chaos
Lost Souls: text based RPG
MUDseek: MUD games search


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group