PHP_FunctionCallTracer | PHPUnit |
PHP_FunctionCallTracer | |
PEAR Manual | |
traceArguments() is used to trace the function arguments. There is no need to pass the function arguments to traceArguments() to trace them. Note that traceArguments() may not be used, if the function does not call any other function or if the function calls functions that are not being traced.
traceVariables() is used to trace variables within the function. The variables to trace must be passed as arguments to traceVariables(). traceVariables() may be called as many times as required to watch variables value change.
traceReturn() is used to trace the variables returned by the function. The variables to trace must be passed as arguments to traceReturn().
putTrace() is used to display the trace to the standard output or to write it into a file.
In this example, package.php contains two classes whose methods are traced. The package is used by an application trace.php. The trace is stored into trace.txt. To generate the trace, run: #php trace.php.
The package package.php
Note that testing if PHP_FunctionCallTracer is loaded: class_exists('PHP_FunctionCallTracer', false), is optional. It is useful only if the tracing methods are meant to be left in the code. They will be called only if PHP_FunctionCallTracer is loaded.
|
The application trace.php
|
The trace trace.txt
Array ( [php_uname] => Windows NT mybox 5.1 build 2600 [date] => Friday, 03-Aug-07 09:17:30 UTC [calls] => Array ( [0] => Array ( [call] => Array ( [file] => trace.php [line] => 20 [function] => geometry->circle ) [in] => Array ( [file] => package.php [line] => 55 [args] => Array ( [0] => 2 ) ) [out] => Array ( [file] => package.php [line] => 61 [args] => Array ( [0] => 12.56 [1] => 6.28 ) ) ) [1] => Array ( [call] => Array ( [file] => package.php [line] => 58 [function] => math::prod ) [in] => Array ( [file] => package.php [line] => 22 [args] => Array ( [0] => 2 [1] => 6.28 ) ) [out] => Array ( [file] => package.php [line] => 22 [args] => Array ( [0] => 12.56 ) ) ) [2] => Array ( [call] => Array ( [file] => trace.php [line] => 21 [function] => geometry->disk ) [in] => Array ( [file] => package.php [line] => 71 [args] => Array ( [0] => 3 ) ) [watches] => Array ( [0] => Array ( [file] => package.php [line] => 75 [args] => Array ( [0] => 9 [1] => 3.14 ) ) ) [out] => Array ( [file] => package.php [line] => 80 [args] => Array ( [0] => 28.26 ) ) ) [3] => Array ( [call] => Array ( [file] => package.php [line] => 73 [function] => math::square ) [in] => Array ( [file] => package.php [line] => 35 [args] => Array ( [0] => 3 ) ) [out] => Array ( [file] => package.php [line] => 40 [args] => Array ( [0] => 9 ) ) ) [4] => Array ( [call] => Array ( [file] => package.php [line] => 37 [function] => math::prod ) [in] => Array ( [file] => package.php [line] => 22 [args] => Array ( [0] => 3 [1] => 3 ) ) [out] => Array ( [file] => package.php [line] => 22 [args] => Array ( [0] => 9 ) ) ) [5] => Array ( [call] => Array ( [file] => package.php [line] => 77 [function] => math::prod ) [in] => Array ( [file] => package.php [line] => 22 [args] => Array ( [0] => 9 [1] => 3.14 ) ) [out] => Array ( [file] => package.php [line] => 22 [args] => Array ( [0] => 28.26 ) ) ) ) [objects] => Array ( [0] => geometry Object ( [pi:private] => 3.14 ) [2] => same as #0 ) ) |
PHP_FunctionCallTracer | PHPUnit |
PHP_FunctionCallTracer | |
PEAR Manual | |