PHP/Development/Debug

Материал из Web эксперт
Версия от 10:04, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

A Function to Format Debugging Messages

   <source lang="html4strict">

<?php function debug( $line, $msg ){

   static $calls = 1;
print "



\n";
   print "DEBUG $calls: Line $line: $msg
"; $args = func_get_args(); if ( count( $args ) % 2 ) print "Odd number of args
"; else{ for ( $x=2; $x< count($args); $x += 2 ){ print "&nbsp  \$$args[$x]: ".$args[$x+1]; print " .... (".gettype( $args[$x+1] ).")
\n"; } }
print "
<p>

\n";
   $calls++;

} $test = 55; debug( __LINE__, "First message", "test", $test ); $test = 66; $test2 = $test/2; debug( __LINE__, "Second message", "test", $test, "test2", $test2 ); ?>

      </source>