PHP_Debug
[ class tree: PHP_Debug ] [ index: PHP_Debug ] [ all elements ]

Source for file PHP_Debug_HTML_Table_test.php

Documentation is available at PHP_Debug_HTML_Table_test.php

  1. <?php
  2.  
  3. /**
  4.  * Created on 18 apr 2006
  5.  *
  6.  * Test script for PHP_Debug 2.0.0
  7.  * 
  8.  * @package PHP_Debug
  9.  * @author  COil
  10.  * @since V2.0.0 - 6 apr 2006
  11.  * @filesource
  12.  * 
  13.  * @version    CVS: $Id: PHP_Debug_HTML_Table_test.php,v 1.5 2009/01/12 21:13:00 c0il Exp $
  14.  */
  15.  
  16. error_reporting(E_ALL)// Report all possible errors
  17. //session_start();      // Start session
  18.  
  19. $renderer 'HTML_Table';
  20.  
  21. // Options array for Debug object
  22. $options = array(
  23.     'render_type'          => 'HTML',
  24.     'render_mode'          => 'Table',
  25.     'restrict_access'      => false,
  26.     'allow_url_access'     => true,
  27.     'url_key'              => 'key',
  28.     'url_pass'             => 'nounou',
  29.     'enable_watch'         => false,
  30.     'replace_errorhandler' => true,
  31.     'lang'                 => 'FR',
  32.     'HTML_TABLE_view_source_script_name' => 'PHP_Debug_ShowSource.php',
  33.     'HTML_TABLE_css_path'        => 'css'
  34. );
  35.  
  36. $allowedip = array
  37.     '127.0.0.1'
  38. );
  39.  
  40.  
  41. require_once 'PHP/Debug.php';
  42.  
  43. echo '<?xml version="1.0" encoding="UTF-8"?>
  44. <!DOCTYPE html 
  45.      PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  46.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  47. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  48.   <head>
  49.     <title>Pear::PHP_Debug</title>
  50.     <link rel="stylesheet" type="text/css" media="screen" href="'$options['HTML_TABLE_css_path'.'/html_table.css" />
  51. ';
  52. ?>
  53.   </head>
  54. <body>
  55. <h1>PEAR::PHP_Debug</h1>
  56. <p>
  57.     <a href="http://validator.w3.org/check?uri=referer"><img
  58.         src="http://www.w3.org/Icons/valid-xhtml10"
  59.         alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
  60. </p>
  61.  
  62. <p>
  63.     <a href="PHP_Debug_HTML_Div_test.php">&raquo; HTML_DIV Renderer</a><br/>
  64.     <a href="PHP_Debug_HTML_Table_test.php">&raquo; HTML_Table Renderer</a><br/>
  65.     <a href="PHP_Debug_test.php">&raquo; Test min</a><br/>
  66.     <a href="PHP_Debug_Sources.php">&raquo; Show sources</a><br/>
  67.     <a href="http://www.php-debug.com">&raquo; Back to PHP_Debug home</a><br/>
  68. </p>
  69.  
  70. <?php
  71. // Tests variables  ============================================================
  72.  
  73. // One variable that will be watched by PHP_Debug
  74. $watchedVariable = 1; 
  75.  
  76. // One session variable to test the debugtype = PHP_DebuLine::TYPE_ENV (4)
  77. $_SESSION['Kikoo''One session variable defined';
  78.  
  79.  
  80. // Debug Object creation =======================================================
  81.  
  82. $Dbg = new PHP_Debug($options);
  83.  
  84.  
  85. // Test restrictAcess() function, only IP in param array will see the debug ====
  86. $Dbg->restrictAccess($allowedip);
  87.  
  88.  
  89. // Test add() function =========================================================
  90.  
  91. // Standard 
  92. $Dbg->add("This is the <b>HTML_Table_Render</b>, client IP is "
  93.     $_SERVER['REMOTE_ADDR']);
  94.  
  95. // Standard, fix end and start time manually
  96. $debug_line $Dbg->add('Manual performance monitoring');
  97. $debug_line->setStartTime();
  98. for ($i = 0; $i < 20000; $i++{
  99.     $j = 0;
  100. }
  101. $debug_line->setEndTime();
  102.  
  103. // Test dump() function ========================================================
  104.  
  105. // dump a variable (integer)
  106. $foo = 555;
  107. $Dbg->dump($foo'Foo');
  108.  
  109. // dump a variable (double)
  110. $foo2 = 37.2;
  111. $Dbg->dump($foo2'Foo2');
  112.  
  113. // dump an array
  114. //$Dbg->dump($options, 'Options');
  115.  
  116. // dump an object
  117. $testObject = new PHP_DebugLine('info info info inside DebugLine object');
  118. $Dbg->dump($testObject);
  119.  
  120. // dump an object and die the script 
  121. //PHP_Debug::dumpVar($testObject, 'stooooooop', true);
  122.  
  123.  
  124. // Test setAction() ============================================================
  125.  
  126.  
  127. // Type 12 : Page action : --> Methode publique a creer
  128. $action 'view_test_action';
  129. $Dbg->setAction($action);
  130.  
  131.  
  132. // Test watch() function, watched var is 'watchedVariable' =====================
  133.  
  134. // /!\ Be carefull the tick directive does not work under windows /!\
  135. // and make apache crash. To test under unix, remove comments bellow and
  136. // corresponding brace line 170 
  137.   
  138. //declare (ticks = 1) 
  139. //{  // <-- uncomment here
  140.  
  141.     // Watch the variable called 'watchedVariable' 
  142.     //$Dbg->watch('watchedVariable');
  143.  
  144.     // Stress backtrace function (check line, file, function, class results) ===
  145.  
  146.     function a()
  147.     {
  148.         global $Dbg$watchedVariable;
  149.         $Dbg->addDebug('call from a() fonction');
  150.         $Dbg->stopTimer();
  151.     
  152.         $watchedVariable = 501;
  153.         
  154.         b();
  155.     }
  156.     
  157.     function b()
  158.     {
  159.         global $Dbg$watchedVariable;
  160.         $Dbg->add('call from b() fonction');
  161.     
  162.         $watchedVariable = 502;
  163.     }
  164.  
  165.     a();
  166.     
  167.     $Dbg->addDebugFirst('call after b() and a() but adding in 1st');
  168.     
  169.     $watchedVariable = 555;    
  170.     $watchedVariable 'converting from INT to STR';
  171.  
  172. //} // End of declare {ticks=n}  block   <-- uncomment here
  173.  
  174.  
  175. // Test the add() function with the timer ======================================
  176.  
  177. $Dbg->add('PERF TEST : 10000 iteration');
  178.  
  179. $y = 0;
  180. for ($index = 0; $index < 10000; $index++{
  181.     $y $y $index;
  182. }
  183. $Dbg->stopTimer();
  184.  
  185.  
  186. // Test the query() function ===================================================
  187.  
  188. $Dbg->query('SELECT * FROM PHP_DEBUG_USERS');
  189.  
  190. $y = 0;
  191. for ($index = 0; $index < 10000; $index++{
  192.     $y $y $index;
  193. }
  194. $Dbg->stopTimer();
  195.  
  196.  
  197.  
  198. // Test custom error handler ===================================================
  199.  
  200. echo $notset;                      // Will raise a PHP notice
  201. fopen('not existing!''r');       // Will raise a PHP warning
  202. trigger_error('This is a custom application error !!'E_USER_ERROR);
  203.                                    // Will raise a custom user error
  204. $Dbg->error('Bad status of var x in application PHP_Debug');
  205.                                    // Will add an application error
  206.  
  207.  
  208. // Display Debug information (HTML_Table renderer) =============================
  209.  
  210. $Dbg->display();
  211.  
  212.  
  213. // Test __toString(), dumpVar() functions and structure of Debug object ========
  214.  
  215. //echo $Dbg;
  216.  
  217.  
  218. // END =========================================================================
  219. ?>
  220. </body>
  221. </html>

Documentation generated on Mon, 11 Mar 2019 15:28:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.