Login   Register  
PHP Classes
elePHPant
Icontem

File: debug_var.inc.php3

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Aresch Yavari  >  debug_var  >  debug_var.inc.php3  >  Download  
File: debug_var.inc.php3
Role: ???
Content type: text/plain
Description: debug a variable in human readable format
Class: debug_var
Author: By
Last change:
Date: 13 years ago
Size: 2,002 bytes
 

Contents

Class file image Download
<?php
/*
	DEBUG_VAR
	
	usage:    D = new DEBUG();
			D->DEBUG_VAR($var1,"var1");
	
			second parameter is optional     
	
	(c) by DATABAY AG 2001 - ay@databay.de
*/

class DEBUG {

function DEBUG() {}

function debug_var2($V,$Name="") {
	
	$TYPE_COLOR = "RED";
	$NAME_COLOR = "BLUE";
	$VALUE_COLOR = "BLACK";

	$D = "";
	
	if (is_int($V)) {
		$D = "<FONT COLOR=$TYPE_COLOR><B>Integer: </B></FONT>";
		if ($Name!="") $D .= "&#40; <FONT COLOR=$NAME_COLOR>$Name</FONT> &#41; ";
		$D .= " &#91; <FONT COLOR=$VALUE_COLOR>$V</FONT> &#93;";
	}
	if (is_string($V)) {
		$D = "<FONT COLOR=$TYPE_COLOR><B>String: </B></FONT>";
		if ($Name!="") $D .= "&#40; <FONT COLOR=$NAME_COLOR>$Name</FONT> &#41; ";
		$D .= " &#91; <FONT COLOR=$VALUE_COLOR>&quot;$V&quot;</FONT> &#93;";
	}
	if (is_array($V)) {

		$D = "<FONT COLOR=$TYPE_COLOR><B>Array: </B></FONT>";
		if ($Name!="") $D .= "&#40; <FONT COLOR=$NAME_COLOR>$Name</FONT> &#41; ";
		$D .= "<FONT COLOR=$VALUE_COLOR><UL>";

		while(list($key, $val) = each($V)) {
			$D .= DEBUG_VAR2($val,$key); 
		}

		$D .= "</UL></FONT>";
	}
	$D .= "<BR>";
	return($D);

}

function DEBUG_VAR($V,$Name="") {

	$D = $this->DEBUG_VAR2($V,$Name);
	$D .= "<TABLE SIZE=100% CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD><HR SIZE=1></TD><TD WIDTH=1%><FONT FACE='Verdana,arial' SIZE=1>".date("d.m.Y")."&nbsp;".date("H:i:s")."</FONT></TD></TR></TABLE>";

	$alt = @file("./DEBUG_VAR.html");
	$alt[] = "";
	$alt = implode($alt,"");

	$fp = @fopen("./DEBUG_VAR.html","w");
	if ($fp=="") {
		?>
		<SCRIPT>
		alert("DEBUG_VAR need a file at\n./DEBUG_VAR.html\nto write the debug-information into.\nPlease create this file and give writeaccess.");
		</SCRIPT>
		<?php
		exit;
	} else {
		fwrite($fp,$D."\n");
		fwrite($fp,$alt);
		fclose($fp);
	}
	?>
	<SCRIPT>
		w=window.open("DEBUG_VAR.html","DEBUGVAR","WIDTH=450,HEIGHT=500,scrollbars=yes,resizable=yes");
		w.focus();
	</SCRIPT>
	<?php
}              

}
?>