Xdebug doc 因为那个网站老是不能访问。晕倒。
Documentation for: Xdebug 2
? Installation
This section describes on how to install Xdebug.
? Basic Features
Xdebug's basic functions include the display of stack traces on error conditions, maximum nesting level protection and time tracking.
? Variable Display Features
Xdebug replaces PHP's var_dump() function for displaying variables. Xdebug's version includes different colors for different types and places limits on the amount of array elements/object properties, maximum depth and string lengths. There are a few other functions dealing with variable display as well.
? Stack Traces
When Xdebug is activated it will show a stack trace whenever PHP decides to show a notice, warning, error etc. The information that stack traces display, and the way how they are presented, can be configured to suit your needs.
? Function Traces
Xdebug allows you to log all function calls, including parameters and return values to a file in different formats.
? Code Coverage Analysis
Code coverage tells you which lines of script (or set of scripts) have been executed during a request. With this information you can for example find out how good your unit tests are.
? Profiling PHP Scripts
Xdebug's built-in profiler allows you to find bottlenecks in your script and visualize those with an external tool such as KCacheGrind or WinCacheGrind.
? Remote Debugging
Xdebug provides an interface for debugger clients that interact with running PHP scripts. This section explains how to set-up PHP and Xdebug to allow this, and introduces a few clients.
? FAQ
Frequently Asked Questions
<!-- MAIN FEATURE END --> | ||||||
|
Documentation for:
Xdebug 2
» Feature: Variable Display Features Xdebug replaces PHP's var_dump() function for displaying variables. Xdebug's version includes different colors for different types and places limits on the amount of array elements/object properties, maximum depth and string lengths. There are a few other functions dealing with variable display as well. Effect of settings on var_dump()There is a number of settings that control the output of Xdebug's modified var_dump() function: xdebug.var_display_max_children , xdebug.var_display_max_data and xdebug.var_display_max_depth . The effect of these three settings is best shown with an example. The script below is run four time, each time with different settings. You can use the tabs to see the difference. The script The resultsarray 'one' => 'a somewhat long string!' (length=23) 'two' => array 'two.one' => array 'two.one.zero' => 210 'two.one.one' => array ... 'three' => object (test )[1 ] public 'pub' => & object (test )[1 ] private 'priv' => true protected 'prot' => 42 'four' => array 0 => 0 1 => 1 2 => 2 3 => 3 4 => 4 5 => 5 array 'one' => 'a somewhat long string!' (length=23) 'two' => array 'two.one' => array 'two.one.zero' => 210 'two.one.one' => array ... more elements... array 'one' => 'a somewhat long '... (length=23) 'two' => array 'two.one' => array 'two.one.zero' => 210 'two.one.one' => array ... 'three' => object (test )[1 ] public 'pub' => & object (test )[1 ] private 'priv' => true protected 'prot' => 42 'four' => array 0 => 0 1 => 1 2 => 2 3 => 3 4 => 4 5 => 5 array 'one' => 'a somewhat long string!' (length=23) 'two' => array 'two.one' => array ... 'three' => object (test )[1 ] public 'pub' => & object (test )[1 ] private 'priv' => true protected 'prot' => 42 'four' => array 0 => 0 1 => 1 2 => 2 3 => 3 4 => 4 5 => 5 array 'one' => 'a somewh'... (length=23) 'two' => array ... 'three' => object (test )[1 ] ... more elements... Related Settings
xdebug.overload_var_dump
Type:
boolean , Default value:
1 , Introduced in
Xdebug 2.1
By default Xdebug overloads var_dump() with its own improved version for displaying variables when the html_errors php.ini setting is set to 1. In case you do not want that, you can set this setting to 0, but check first if it's not smarter to turn off html_errors.
xdebug.var_display_max_children
Type:
integer , Default value:
128
Controls the amount of array children and object's properties are shown when variables are displayed with either
xdebug_var_dump() ,
xdebug.show_local_vars or through
Function Traces . This setting does not have any influence on the number of children that is send to the client through the
Remote Debugging feature.
xdebug.var_display_max_data
Type:
integer , Default value:
512
Controls the maximum string length that is shown when variables are displayed with either
xdebug_var_dump() ,
xdebug.show_local_vars or through
Function Traces . This setting does not have any influence on the amount of data that is send to the client through the
Remote Debugging feature.
xdebug.var_display_max_depth
Type:
integer , Default value:
3
Controls how many nested levels of array elements and object properties are when variables are displayed with either
xdebug_var_dump() ,
xdebug.show_local_vars or through
Function Traces . This setting does not have any influence on the depth of children that is send to the client through the
Remote Debugging feature.
Related Functions
void var_dump(
[mixed var [, ...]] )
Displays detailed information about a variable
This function is overloaded by Xdebug, see the description for xdebug_var_dump() .
void xdebug_debug_zval(
[string varname [, ...]] )
Displays information about a variable
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.
Example:
<?php
Returns:
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)
void xdebug_debug_zval_stdout(
[string varname [, ...]] )
Returns information about variables to stdout.
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).
Example:
<?php
Returns:
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)
void xdebug_dump_superglobals( )
Displays information about super globals
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:
Example:
xdebug.dump.GET=*
Returns:
void xdebug_var_dump(
[mixed var [, ...]] )
Displays detailed information about a variable
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.
Example:
<?php
Returns:
array 0 => array 0 => true 1 => 2 2 => 3.14 more elements... 'object' => object (stdClass )[1 ] public 'foo' => 'bar' (length=3) public 'file' => resource (3 , stream ) hen Xdebug is activated it will show a stack trace whenever PHP decides to show a notice, warning, error etc. The information that stack traces display, and the way how they are presented, can be configured to suit your needs. The stack traces that Xdebug shows on error situations (if display_errors is set to On in php.ini) are quite conservative in the amount of information that they show. This is because large amounts of information can slow down both the execution of the scripts and the rendering of the stack traces themselves in the browser. However, it is possible to make the stack traces show more detailed information with different settings. Variables in Stack TracesBy default Xdebug will now show variable information in the stack traces that it produces. Variable information can take quite a bit of resources, both while collecting or displaying. However, in many cases it is useful that variable information is displayed, and that is why Xdebug has the setting xdebug.collect_params . The script below, in combination with what the output will look like with different values of this setting is shown in the example below. The script The resultsDifferent values for the xdebug.collect_params setting give different output, which you can see below:
ini_set('xdebug.collect_params', '1');
ini_set('xdebug.collect_params', '2');
ini_set('xdebug.collect_params', '3');
ini_set('xdebug.collect_params', '4');
Additional InformationOn top of showing the values of variables that were passed to each function Xdebug can also optionally show information about selected superglobals by using the xdebug.dump_globals and xdebug.dump.* settings. The settings xdebug.dump_once and xdebug.dump_undefined slightly modify when and which information is shown from the available superglobals. With the xdebug.show_local_vars setting you can instruct Xdebug to show all variables available in the top-most stack level for a user defined function as well. The examples below show this (the script is used from the example above).
ini_set('xdebug.collect_vars', 'on'); ini_set('xdebug.collect_params', '4'); ini_set('xdebug.dump_globals', 'on'); ini_set('xdebug.dump.SERVER', 'REQUEST_URI');
ini_set('xdebug.collect_vars', 'on'); ini_set('xdebug.collect_params', '4'); ini_set('xdebug.dump_globals', 'on'); ini_set('xdebug.dump.SERVER', 'REQUEST_URI'); ini_set('xdebug.show_local_vars', 'on');
Related Settings |