1. <?php
  2.  
  3. class myClass
  4. {
  5.     function myClass()
  6.     {
  7.     }
  8. }
  9.  
  10. $php5 = version_compare(phpversion(), '5.0.0', '>=');
  11.  
  12. if (!$php5) {
  13.     require_once 'dpb3.php';
  14.     require_once 'PHP/Compat.php';
  15.     PHP_Compat::loadFunction('debug_print_backtrace');
  16. }
  17.  
  18. error_reporting (E_ALL);
  19.  
  20. function debug($var, $val)
  21. {
  22.     echo "***Deboggage\nVariable : $var\nValeur :";
  23.     if (is_array($val) || is_object($val) || is_resource($val)) {
  24.         print_r($val);
  25.     } else {
  26.         echo "\n$val\n";
  27.     }
  28.     debug_print_backtrace();
  29.     echo "***\n";
  30. }
  31.  
  32. $host = $_SERVER["SERVER_NAME"];
  33. call_user_func_array('debug', array("host", $host));
  34.  
  35. $myClass = new myClass();
  36. call_user_func_array('debug', array("myClass", $myClass));
  37.  
  38. $fp = fopen('php://stderr', 'wb');
  39. call_user_func_array('debug', array("fp", $fp));
  40. fclose($fp);
  41.  
  42. /*
  43.   fixed debug_print_backtrace :  dpb3.php
  44. --------------------------------------------------------------------------------
  45. ***Deboggage
  46. Variable : host
  47. Valeur :
  48. localhost
  49. #0  debug(host, localhost) called at [(null):0]
  50. #1  call_user_func_array(debug, Array
  51. (
  52.     [0] => host
  53.     [1] => localhost
  54. )
  55. ) called at [(...)\php\debug_print_backtrace.php:33]
  56. ***
  57. ***Deboggage
  58. Variable : myClass
  59. Valeur :myclass Object
  60. (
  61. )
  62. #0  debug(myClass, myclass) called at [(null):0]
  63. #1  call_user_func_array(debug, Array
  64. (
  65.     [0] => myClass
  66.     [1] => myclass Object
  67.         (
  68.         )
  69. )
  70. ) called at [(...)\php\debug_print_backtrace.php:36]
  71. ***
  72. ***Deboggage
  73. Variable : fp
  74. Valeur :Resource id #4
  75. #0  debug(fp, Resource id #4) called at [(null):0]
  76. #1  call_user_func_array(debug, Array
  77. (
  78.     [0] => fp
  79.     [1] => Resource id #4
  80. )
  81. ) called at [(...)\php\debug_print_backtrace.php:39]
  82. ***
  83. --------------------------------------------------------------------------------
  84. */
  85.  
  86. /*
  87.   fixed debug_print_backtrace :  dpb2.php
  88. --------------------------------------------------------------------------------
  89. ***Deboggage
  90. Variable : host
  91. Valeur :
  92. localhost
  93. #0  debug(string host, string localhost) called at [Unknown:Unknown]
  94. #1  call_user_func_array(string debug, array) called at [(...)\php\debug_print_backtrace.php:33]
  95. ***
  96. ***Deboggage
  97. Variable : myClass
  98. Valeur :myclass Object
  99. (
  100. )
  101. #0  debug(string myClass, myclass) called at [Unknown:Unknown]
  102. #1  call_user_func_array(string debug, array) called at [(...)\php\debug_print_backtrace.php:36]
  103. ***
  104. ***Deboggage
  105. Variable : fp
  106. Valeur :Resource id #4#0  debug(string fp, resource) called at [Unknown:Unknown]
  107. #1  call_user_func_array(string debug, array) called at [(...)\php\debug_print_backtrace.php:39]
  108. ***
  109. --------------------------------------------------------------------------------
  110. */
  111.  
  112. /*
  113.   PHP 4.4.2 and PHP/Compat 1.5.0  debug_print_backtrace()
  114. --------------------------------------------------------------------------------
  115. ***Deboggage
  116. Variable : host
  117. Valeur :
  118. localhost
  119. <br />
  120. <b>Notice</b>:  Undefined index:  file in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>46</b><br />
  121. <br />
  122. <b>Notice</b>:  Undefined index:  line in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>46</b><br />
  123. <br />
  124. <b>Notice</b>:  Array to string conversion in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>53</b><br />
  125. #0  debug(host, localhost) called at [:]
  126. #1  call_user_func_array(debug, Array) called at [(...)\php\debug_print_backtrace.php:33]
  127. ***
  128. ***Deboggage
  129. Variable : myClass
  130. Valeur :myclass Object
  131. (
  132. )
  133. <br />
  134. <b>Notice</b>:  Undefined index:  file in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>46</b><br />
  135. <br />
  136. <b>Notice</b>:  Undefined index:  line in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>46</b><br />
  137. <br />
  138. <b>Notice</b>:  Object to string conversion in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>53</b><br />
  139. <br />
  140. <b>Notice</b>:  Array to string conversion in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>53</b><br />
  141. #0  debug(myClass, Object) called at [:]
  142. #1  call_user_func_array(debug, Array) called at [(...)\php\debug_print_backtrace.php:36]
  143. ***
  144. ***Deboggage
  145. Variable : fp
  146. Valeur :Resource id #4<br />
  147. <b>Notice</b>:  Undefined index:  file in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>46</b><br />
  148. <br />
  149. <b>Notice</b>:  Undefined index:  line in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>46</b><br />
  150. <br />
  151. <b>Notice</b>:  Array to string conversion in <b>(...)\php4\pear\PHP\Compat\Function\debug_print_backtrace.php</b> on line <b>53</b><br />
  152. #0  debug(fp, Resource id #4) called at [:]
  153. #1  call_user_func_array(debug, Array) called at [(...)\php\debug_print_backtrace.php:39]
  154. ***
  155. --------------------------------------------------------------------------------
  156. */
  157.  
  158. /*
  159.   PHP 5.1.2  debug_print_backtrace()
  160. --------------------------------------------------------------------------------
  161. ***Deboggage
  162. Variable : host
  163. Valeur :
  164. localhost
  165. #0  debug(host, localhost) called at [(null):0]
  166. #1  call_user_func_array(debug, Array ([0] => host,[1] => localhost)) called at [(...)\php\debug_print_backtrace.php:33]
  167. ***
  168. ***Deboggage
  169. Variable : myClass
  170. Valeur :myClass Object
  171. (
  172. )
  173. #0  debug(myClass, myClass Object ()) called at [(null):0]
  174. #1  call_user_func_array(debug, Array ([0] => myClass,[1] => myClass Object ())) called at [(...)\php\debug_print_backtrace.php:36]
  175. ***
  176. ***Deboggage
  177. Variable : fp
  178. Valeur :Resource id #3
  179. #0  debug(fp, Resource id #3) called at [(null):0]
  180. #1  call_user_func_array(debug, Array ([0] => fp,[1] => Resource id #3)) called at [(...)\php\debug_print_backtrace.php:39]
  181. ***
  182. --------------------------------------------------------------------------------
  183. */
  184.  
  185. ?>