Source for file index.php
Documentation is available at index.php
* Test script for PHP_Debug2
//session_start(); // Start session
// Get default stylesheet
require_once 'Debug.php';
require_once 'Debug/Renderer/HTML_Table_Config.php';
print ('<?xml version="1.0" encoding="UTF-8"?>
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Pear::PHP_Debug</title>
// Get stysheet and print it
print ($HTMLoptions['HTML_TABLE_stylesheet']);
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
// Tests variables ============================================================
// One variable that will be watched by PHP_Debug
// One session variable to test the debugtype = PHP_DEBUGLINE_ENV (4)
//$_SESSION['Kikoo'] = "One session variable defined";
// Options array for Debug object
'DEBUG_restrict_access' => false,
'DEBUG_allow_url_access' => true,
'DEBUG_url_key' => 'key',
'DEBUG_url_pass' => 'nounou',
'DEBUG_enable_watch' => false,
'DEBUG_replace_errorhandler' => true,
'HTML_TABLE_view_source_script_name' => 'source.php'
// Debug Object creation =======================================================
$Dbg = new Debug($options);
// Test restrictAcess() function, only IP in param array will see the debug ====
//$Dbg->restrictAcess($allowedip);
// Test add() function =========================================================
$Dbg->add("This is the <b>HTML_Table_Render</b>, client IP is ". $_SERVER['REMOTE_ADDR']);
// Test dump() function ========================================================
// dump a variable (integer)
// dump a variable (double)
$Dbg->dump($foo2, "Foo2");
$Dbg->dump($options, "Options");
$testObject = new Debug_Line("info info info inside Debug_Line object");
// Test setAction() ============================================================
// Type 12 : Page action : --> Methode publique a creer
$action = 'view_debug_test_action';
$Dbg->setAction($action);
// Test watch() function, watched var is 'watchedVariable' =====================
// /!\ Be carefull the tick directive does not work under windows /!\
// and make apache crash. To test under unix, remove comments bellow and
// corresponding brace line 152
// Watch the variable called 'watchedVariable'
//$Dbg->watch("watchedVariable");
// Stress backtrace function (check line, file, function, class results) =======
global $Dbg,$watchedVariable;
$Dbg->addDebug("call from a() fonction");
global $Dbg, $watchedVariable;
$Dbg->add("call from b() fonction");
$Dbg->addDebugFirst("call after b() and a() but adding in 1st");
$watchedVariable = 'converting from INT to STR';
// } // End of declare {ticks=n} block
// Test the add() function with the timer ======================================
$Dbg->add("PERF TEST : 10000 iteration");
for ($index = 0; $index < 10000; $index++ )
// Test the query() function ===================================================
$Dbg->query("SELECT * FROM PHPDEBUG_USERS");
for ($index = 0; $index < 5000; $index++ )
// Test custom error handler ===================================================
echo $notset; // Will raise a PHP notice
fopen('not existing!', 'r'); // Will raise a PHP warning
trigger_error('This is a custom application error !!', E_USER_ERROR);
// Will raise a custom user error
$Dbg->error('Bad status of var x in application PHP_Debug');
// Will add an application error
// Display Debug information (HTML_Table renderer) =============================
// Test __toString(), dumpVar() functions and structure of Debug object ========
// Display source code =========================================================
foreach ($Dbg->getRequiredFiles() as $lvalue)
print ("<h1>$lvalue</h1>");
// END =========================================================================
|