xdebug 执行跟踪脚本的设置
[xdebug]
zdebug.extended_info - 0
xdebug.auto_trace =1
xdebug.trace_output_dir = "C:/xampp/tmp/xdebug/trace"
xdebug.collect_includes=1
xdebug.show_mem_delta=1
xdebug.collect_return=1
xdebug.sollect_params=1
xdebug.remote_enable=0
xdebug.profiler_enable=0
性能分析设置
xdebug.auto_trace =0
xdebug.collect_return=0
xdebug.sollect_params=0
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:/xampp/tmp/xdebug/profiler"
其它设置项及说明:
xdebug.profiler_append = 1 改变这种行为并将后续运行追加到相同的文件
xdebug.default_enable=On 显示栈跟踪
xdebug.show_local_vars=1 来进一步显示最顶部范围内的所有变量
xdebug.var_display_max_children、
xdebug.var_display_max_data
xdebug.var_display_max_depth
是相关的三个设置,分别用来控制因 xdebug.show_local_vars 的使用而显示的变量的属性数、字符串长度和嵌套深度。
分别用来控制因 xdebug.show_local_vars 的使用而显示的变量的属性数、字符串长度和嵌套深度。
函数篇
void var_dump( [mixed var [, ...]] )
This function is overloaded by Xdebug, see the description for xdebug_var_dump().
This function makes the debugger break on the specific line as if a normal file/line breakpoint was set on this line.
This function returns the name of the class from which the current function/method was called from.
<?php
functionfix_string($a)
{
echo"Called@".
xdebug_call_file().
":".
xdebug_call_line().
"from".
xdebug_call_function();
}
$ret=fix_string(array('Derick'));
?>
Called @ /home/httpd/html/test/xdebug_caller.php:12 from {main}
This function returns the filename that contains the function/method that called the current function/method.
For an example see xdebug_call_class().
This function returns the name of the function/method from which the current function/method was called from.
For an example see xdebug_call_class().
This function returns the line number that contains the function/method that called the current function/method.
For an example see xdebug_call_class().
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. This function is implemented differently from PHP's debug_zval_dump() function in order to work around the problems that that function has because the variable itself is actually passed to the function. Xdebug's version is better as it uses the variable name to lookup the variable in the internal symbol table and accesses all the properties directly without having to deal with actually passing a variable to a function. The result is that the information that this function returns is much more accurate than PHP's own function for showing zval information.
<?php
$a=array(1,2,3);
$b=&$a;
$c=&$a[2];
xdebug_debug_zval('a');
?>
a: (refcount=2, is_ref=1)=array (
0 => (refcount=1, is_ref=0)=1,
1 => (refcount=1, is_ref=0)=2,
2 => (refcount=2, is_ref=1)=3)
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. The difference with xdebug_debug_zval() is that the information is not displayed through a web server API layer, but directly shown on stdout (so that when you run it with apache in single process mode it ends up on the console).
<?php
$a=array(1,2,3);
$b=&$a;
$c=&$a[2];
xdebug_debug_zval_stdout('a');
a: (refcount=2, is_ref=1)=array (
0 => (refcount=1, is_ref=0)=1,
1 => (refcount=1, is_ref=0)=2,
2 => (refcount=2, is_ref=1)=3)
Disable showing stack traces on error conditions.
This function dumps the values of the elements of the super globals as specified with the xdebug.dump.* php.ini settings. For the example below the settings in php.ini are:
xdebug.dump.GET=*
xdebug.dump.SERVER=REMOTE_ADDR
Querystring:
?var=fourty%20two&array[a]=a&array[9]=b
Dump $_SERVER | ||||
---|---|---|---|---|
$_SERVER['REMOTE_ADDR']= | (length=9) | |||
Dump $_GET | ||||
$_GET['var']= | (length=10) | |||
$_GET['array']= | array |
Enable showing stack traces on error conditions.
Returns a structure which contains information about which lines were executed in your script (including include files). The following example shows code coverage for one specific file:
<?php
xdebug_start_code_coverage();
functiona($a){
echo$a*2.5;
}
functionb($count){
for($i=0;$i<$count;$i++){
a($i+0.17);
}
}
b(6);
b(10);
var_dump(xdebug_get_code_coverage());
?>
array
'/home/httpd/html/test/xdebug/docs/xdebug_get_code_coverage.php'
array
5
6
7
9
10
11
12
13
15
16
18
Returns an array where each element is a variable name which is defined in the current scope. The setting xdebug.collect_vars needs to be enabled.
<?php
classstrings{
staticfunctionfix_strings($a,$b){
foreach($bas$item){
}
var_dump(xdebug_get_declared_vars());
}
}
strings::fix_strings(array(1,2,3),array(4,5,6));
?>
array
0 (length=1)
1 (length=1)
2 (length=4)
In PHP versions before 5.1, the variable name "a" is not in the returned array, as it is not used in the scope where the function xdebug_get_declared_vars() is called in.
Returns an array which resembles the stack trace up to this point. The example script:
<?php
classstrings{
functionfix_string($a)
{
var_dump(xdebug_get_function_stack());
}
functionfix_strings($b){
foreach($bas$item){
$this->fix_string($item);
}
}
}
$s=newstrings();
$ret=$s->fix_strings(array('Derick'));
?>
array
0
array
'function' (length=6)
'file' (length=63)
'line'
'params'
array
1
array
'function' (length=11)
'class' (length=7)
'file' (length=63)
'line'
'params'
array
'b' (length=21)
2
array
'function' (length=10)
'class' (length=7)
'file' (length=63)
'line'
'params'
array
'a' (length=8)
Returns the name of the file which is used to save profile information to.
Returns the stack depth level. The main body of a script is level 0 and each include and/or function call adds one to the stack depth level.
Returns the name of the file which is used to trace the output of this script too. This is useful when xdebug.auto_trace is enabled.
Return whether stack traces would be shown in case of an error or not.
Returns the current amount of memory the script uses. Before PHP 5.2.1, this only works if PHP is compiled with --enable-memory-limit. From PHP 5.2.1 and later this function is always available.
Returns the maximum amount of memory the script used until now. Before PHP 5.2.1, this only works if PHP is compiled with --enable-memory-limit. From PHP 5.2.1 and later this function is always available.
This function starts gathering the information for code coverage. The information that is collected consists of an two dimensional array with as primairy index the executed filename and as secondary key the line number. The value in the elements represents the total number of execution units on this line have been executed.
Options to this function are: XDEBUG_CC_UNUSED Enables scanning of code to figure out which line has executable code. XDEBUG_CC_DEAD_CODE Enables branch analyzes to figure out whether code can be executed.
Start tracing function calls from this point to the file in the trace_file parameter. If no filename is given, then the trace file will be placed in the directory as configured by the xdebug.trace_output_dir setting. In case a file name is given as first parameter, the name is relative to the current working directory. This current working directory might be different than you expect it to be, so please use an absolute path in case you specify a file name. Use the PHP function getcwd() to figure out what the current working directory is.
The name of the trace file is "{trace_file}.xt". If xdebug.auto_trace is enabled, then the format of the filename is "{filename}.xt" where the "{filename}" part depends on the xdebug.trace_output_name setting. The options parameter is a bitfield; currently there are three options:
-
XDEBUG_TRACE_APPEND (1)
- makes the trace file open in append mode rather than overwrite mode XDEBUG_TRACE_COMPUTERIZED (2)
- creates a trace file with the format as described under 1 " xdebug.trace_format". XDEBUG_TRACE_HTML (4)
- creates a trace file as an HTML table
This function stops collecting information, the information in memory will not be destroyed so that you can resume the gathering of information with the xdebug_start_code_coverage() function again.
Stop tracing function calls and closes the trace file.
Returns the current time index since the starting of the script in seconds.
<?php
echoxdebug_time_index(),"/n";
for($i=0;$i<250000;$i++)
{
//donothing
}
echoxdebug_time_index(),"/n";
?>
0.00038003921508789
0.76580691337585
This function displays structured information about one or more expressions that includes its type and value. Arrays are explored recursively with values. See the introduction of Variable Display Features on which php.ini settings affect this function.
<?php
ini_set('xdebug.var_display_max_children',3);
$c=newstdClass;
$c->foo='bar';
$c->file=fopen('/etc/passwd','r');
var_dump(
array(
array(TRUE,2,3.14,'foo'),
'object'=>$c
)
);
?>
array
0
array
0
1
2
more elements...
'object'
object(stdClass)[1]
public 'foo' (length=3)
public 'file' resource(3 stream)