Rev 130 Rev 139
1 <?php 1 <?php
2 // +----------------------------------------------------------------------+ 2 // +----------------------------------------------------------------------+
3 // | PHP Version 4 | 3 // | PHP Version 4 |
4 // +----------------------------------------------------------------------+ 4 // +----------------------------------------------------------------------+
5 // | Copyright (c) 1997-2004 The PHP Group | 5 // | Copyright (c) 1997-2004 The PHP Group |
6 // +----------------------------------------------------------------------+ 6 // +----------------------------------------------------------------------+
7 // | This source file is subject to version 3.0 of the PHP license, | 7 // | This source file is subject to version 3.0 of the PHP license, |
8 // | that is bundled with this package in the file LICENSE, and is | 8 // | that is bundled with this package in the file LICENSE, and is |
9 // | available at through the world-wide-web at | 9 // | available at through the world-wide-web at |
10 // | http://www.php.net/license/3_0.txt. | 10 // | http://www.php.net/license/3_0.txt. |
11 // | If you did not receive a copy of the PHP license and are unable to | 11 // | If you did not receive a copy of the PHP license and are unable to |
12 // | obtain it through the world-wide-web, please send a note to | 12 // | obtain it through the world-wide-web, please send a note to |
13 // | license@php.net so we can mail you a copy immediately. | 13 // | license@php.net so we can mail you a copy immediately. |
14 // +----------------------------------------------------------------------+ 14 // +----------------------------------------------------------------------+
15 // | Authors: Laurent Laville <pear@laurent-laville.org> | 15 // | Authors: Laurent Laville <pear@laurent-laville.org> |
16 // | Aidan Lister <aidan@php.net> | 16 // | Aidan Lister <aidan@php.net> |
17 // +----------------------------------------------------------------------+ 17 // +----------------------------------------------------------------------+
18 // 18 //
19 // $Id: debug_print_backtrace.php,v 1.3 2005/08/17 02:58:09 aidan Exp $ 19 // $Id: debug_print_backtrace.php,v 1.3 2005/08/17 02:58:09 aidan Exp $
20   20  
21   21  
22 /** 22 /**
23 * Replace debug_print_backtrace() 23 * Replace debug_print_backtrace()
24 * 24 *
25 * @category PHP 25 * @category PHP
26 * @package PHP_Compat 26 * @package PHP_Compat
27 * @link http://php.net/function.debug_print_backtrace 27 * @link http://php.net/function.debug_print_backtrace
28 * @author Laurent Laville <pear@laurent-laville.org> 28 * @author Laurent Laville <pear@laurent-laville.org>
29 * @author Aidan Lister <aidan@php.net> 29 * @author Aidan Lister <aidan@php.net>
30 * @version $Revision: 1.3 $ 30 * @version $Revision: 1.3 $
31 * @since PHP 5 31 * @since PHP 5
32 * @require PHP 4.3.0 (debug_backtrace) 32 * @require PHP 4.3.0 (debug_backtrace)
33 */ 33 */
34 if (!function_exists('debug_print_backtrace')) { 34 if (!function_exists('debug_print_backtrace')) {
35 function debug_print_backtrace() 35 function debug_print_backtrace()
36 { 36 {
37 // Get backtrace 37 // Get backtrace
38 $backtrace = debug_backtrace(); 38 $backtrace = debug_backtrace();
39   39  
40 // Unset call to debug_print_backtrace 40 // Unset call to debug_print_backtrace
41 array_shift($backtrace); 41 array_shift($backtrace);
42 42
43 // Iterate backtrace 43 // Iterate backtrace
44 $calls = array(); 44 $calls = array();
45 foreach ($backtrace as $i => $call) { 45 foreach ($backtrace as $i => $call) {
46 $location = $call['file'] . ':' . $call['line']; 46 $location = $call['file'] . ':' . $call['line'];
47 $function = (isset($call['class'])) ? 47 $function = (isset($call['class'])) ?
48 $call['class'] . '.' . $call['function'] : 48 $call['class'] . '.' . $call['function'] :
49 $call['function']; 49 $call['function'];
50 50
51 $params = ''; 51 $params = '';
52 if (isset($call['args'])) { 52 if (isset($call['args'])) {
53 $params = implode(', ', $call['args']); 53 $params = implode(', ', $call['args']);
54 } 54 }
55   55  
56 $calls[] = sprintf('#%d %s(%s) called at [%s]', 56 $calls[] = sprintf('#%d %s(%s) called at [%s]',
57 $i, 57 $i,
58 $function, 58 $function,
59 $params, 59 $params,
60 $location); 60 $location);
61 } 61 }
62   62  
63 echo implode("\n", $calls); 63 echo implode("\n", $calls);
64 } 64 }
65 } 65 }
66   66  
67 ?> 67 ?>
68 68