Feature #20856

debug in t3lib

Added by David Bruchmann over 11 years ago. Updated almost 8 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


as addition or as replacement of t3lib_div::debug I wrote some debug-functions (I use them in an own extension).
Default call is like this:


$tmpHint is a text, that can be defined as Hint.
$myVar is the variable to debug, once as string, once as var,
The Rest is filled automatically and points to class, function and line where the call is localized.

Objects are much easier to view because they are rendered with more information and as table instead of simple text.
Try it, think about it, and please comment:

function debug($input,$file='',$classname='',$functionname='',$varname='',$position='',$addInfo='') {
$tmpType = $this->getType($input);
if ($classname || $functionname || $varname) {
$widthFirstCol = ' style="width:15em"';
$styleObjRow = ' style="color:#800"';
$name = '<table style="font-size:10px;font-weight:bold;border:0 ;width:100%" border="1">';
$name .= $position ? '<tr><td'.$widthFirstCol.'>File:</td><td title="File: '.$file.'">'.$file.'</td></tr>' : '';
$name .= !$classname ? '<tr><td'.$widthFirstCol.'>Class:</td><td title="Class: '.get_called_class().'">'.get_called_class().'</td></tr>' : '<tr><td>Class:</td><td title="Class: '.$classname.'">'.$classname.'</td></tr>';
$name .= $functionname ? '<tr><td'.$widthFirstCol.'>'.($classname ? 'Method' : 'Function').':</td><td title="'.($classname ? 'Method' : 'Function').': '.$functionname.'">'.$functionname.'</td></tr>' : '';
$name .= $varname ? '<tr'.$styleObjRow.'><td'.$widthFirstCol.'>'.$tmpType.':</td><td title="'.$tmpType.': '.$varname.'">'.$varname.'</td></tr>' : '';
$name .= $position ? '<tr><td'.$widthFirstCol.'>Line or Position:</td><td title="Line or Position: '.$position.'">'.$position.'</td></tr>' : '';
$name .= $addInfo ? '<tr><td'.$widthFirstCol.'>Additional Info:</td><td title="Additional Info: '.$addInfo.'">'.nl2br(wordwrap($addInfo,100)).'</td></tr>' : '';
$name .= '</table>';
if ($tmpType == 'object') {
else {
function getType ($input) {        
$type = "string";
if (is_array($input)) $type = "array";
elseif (is_object($input)) $type = "object";
elseif (is_resource($input)) $type = "resource";
elseif (is_int($input)) $type = "int";
elseif (is_float($input)) $type = "float";
elseif (is_bool($input)) $type = "bool";
return $type;
function debug_object ($input,$name='') {
$obj['Type'] = 'object';
$obj['Classname'] = get_class($input);
$obj['Parent Class'] = get_parent_class($input);
$obj['Methods'] = get_class_methods($obj['Classname']);
$obj['Class Vars'] = get_class_vars($obj['Classname']);
$obj['Object Vars'] = get_object_vars($input);
$obj['Implemented Interfaces'] = class_implements($input);
$debugTitle = $obj['Classname'];
//if ($input === $this) $debugTitle .= ' ($this)';
$this->debug_array($obj,($name ? $name : '')); //$debugTitle
function debug_array($input,$name) {
echo '

<table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="#eeeeee" style="border:2px solid; margin-top:1em; margin-bottom:1em;">
<td style="background-color:#eee; font-family: verdana,arial; font-weight: bold; font-size: 10px;">


(issue imported from #M11680)


Updated by David Bruchmann over 11 years ago

Inside the functions linking to each other it's better to write [Class]::[function]
So there is no need to instantiate anything.

Reordering of Parameters can be considered because the call perhaps is easier to note if individual parts follow directly:



Updated by Chris topher almost 11 years ago

Not in Core List; what should we do with this?


Updated by Alexander Opitz almost 8 years ago

  • Status changed from New to Closed
  • Target version deleted (0)
  • TYPO3 Version set to 4.3

No response in over one year => closed.

Also available in: Atom PDF