php调试器 xdebug
fmms
13年前
xdebug是一个开源的php调试器,以php模块的形式加载并被使用。 <br /> <br /> <span class="serif"> <p class="intro">Xdebug的基本功能包括堆栈跟踪显示错误,最大嵌套级别的保护,并及时跟踪。<br /> <br /> </p> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1322626929671" target="_blank">http://www.open-open.com/lib/view/home/1322626929671</a></p> <p class="intro"> </p> <hr class="light" /> <hr style="clear:both;" /> <p></p> <h2>Related Settings</h2> <div class="settings"> <a name="default_enable"></a> <hr class="light" /> <div class="name"> xdebug.default_enable </div> Type: <span class="type">boolean</span>, Default value: <span class="default">1</span> <div class="description"> If this setting is 1, then stacktraces will be shown by default on an error event. You can disable showing stacktraces from your code with <a href="/misc/goto?guid=4959221769228726589">xdebug_disable()</a>. As this is one of the basic functions of Xdebug, it is advisable to leave this setting set to 1. </div> <a name="max_nesting_level"></a> <hr class="light" /> <div class="name"> xdebug.max_nesting_level </div> Type: <span class="type">integer</span>, Default value: <span class="default">100</span> <div class="description"> Controls the protection mechanism for infinite recursion protection. The value of this setting is the maximum level of nested functions that are allowed before the script will be aborted. </div> <a name="scream"></a> <hr class="light" /> <div class="name"> xdebug.scream </div> Type: <span class="type">boolean</span>, Default value: <span class="default">0</span>, Introduced in <span class="type">Xdebug 2.1</span> <div class="description"> If this setting is 1, then Xdebug will disable the @ (shut-up) operator so that notices, warnings and errors are no longer hidden. </div> </div> <hr /> <h2>Related Functions</h2> <div class="functions"> <a name="xdebug_call_class"></a> <hr class="light" /> <div class="name"> <span class="type">string</span> xdebug_call_class() </div> <div class="short-description"> Returns the calling class </div> <div class="description"> <p>This function returns the name of the class from which the current function/method was called from. </p> <div class="example"> <strong>Example:</strong> <br /> <br /> <code><span style="color:#000000;"><span style="color:#0000bb;"><?php<br /> </span><span style="color:#007700;">function </span><span style="color:#0000bb;">fix_string</span><span style="color:#007700;">(</span><span style="color:#0000bb;">$a</span><span style="color:#007700;">)<br /> {<br /> echo </span><span style="color:#dd0000;">"Called @ "</span><span style="color:#007700;">.<br /> </span><span style="color:#0000bb;">xdebug_call_file</span><span style="color:#007700;">().<br /> </span><span style="color:#dd0000;">":"</span><span style="color:#007700;">.<br /> </span><span style="color:#0000bb;">xdebug_call_line</span><span style="color:#007700;">().<br /> </span><span style="color:#dd0000;">" from "</span><span style="color:#007700;">.<br /> </span><span style="color:#0000bb;">xdebug_call_function</span><span style="color:#007700;">();<br /> }<br /> <br /> </span><span style="color:#0000bb;">$ret </span><span style="color:#007700;">= </span><span style="color:#0000bb;">fix_string</span><span style="color:#007700;">(array(</span><span style="color:#dd0000;">'Derick'</span><span style="color:#007700;">));<br /> </span><span style="color:#0000bb;">?><br /> </span><br /> </span></code> </div> <div class="example-returns"> <strong>Returns:</strong> <br /> <br /> <pre>Called @ /home/httpd/html/test/xdebug_caller.php:12 from {main}</pre> </div> </div> <a name="xdebug_call_file"></a> <hr class="light" /> <div class="name"> <span class="type">string</span> xdebug_call_file() </div> <div class="short-description"> Returns the calling file </div> <div class="description"> <p>This function returns the filename that contains the function/method that called the current function/method. </p> <p>For an example see <a href="/misc/goto?guid=4959221769313391505">xdebug_call_class()</a>.</p> </div> <a name="xdebug_call_function"></a> <hr class="light" /> <div class="name"> <span class="type">string</span> xdebug_call_function() </div> <div class="short-description"> Returns the calling function/method </div> <div class="description"> <p>This function returns the name of the function/method from which the current function/method was called from. </p> <p>For an example see <a href="/misc/goto?guid=4959221769313391505">xdebug_call_class()</a>.</p> </div> <a name="xdebug_call_line"></a> <hr class="light" /> <div class="name"> <span class="type">int</span> xdebug_call_line() </div> <div class="short-description"> Returns the calling line </div> <div class="description"> <p>This function returns the line number that contains the function/method that called the current function/method. </p> <p>For an example see <a href="/misc/goto?guid=4959221769313391505">xdebug_call_class()</a>.</p> </div> <a name="xdebug_disable"></a> <hr class="light" /> <div class="name"> <span class="type">void</span> xdebug_disable() </div> <div class="short-description"> Disables stack traces </div> <div class="description"> <p>Disable showing stack traces on error conditions.</p> </div> <a name="xdebug_enable"></a> <hr class="light" /> <div class="name"> <span class="type">void</span> xdebug_enable() </div> <div class="short-description"> Enables stack traces </div> <div class="description"> <p>Enable showing stack traces on error conditions.</p> </div> <a name="xdebug_get_collected_errors"></a> <hr class="light" /> <div class="name"> <span class="type">void</span> xdebug_get_collected_errors( <span class="type">[int clean]</span> ) </div> <div class="short-description"> Returns all collected error messages </div> <div class="version"> Introduced in version 2.1 </div> <div class="description"> <p>This function returns all errors from the collection buffer that contains all errors that were stored there when error collection was started with <a href="/misc/goto?guid=4959221769409368628">xdebug_start_error_collection()</a>. </p> <p>By default this function will not clear the error collection buffer. If you pass true as argument to this function then the buffer will be cleared as well. </p> <p>This function returns a string containing all collected errors formatted as an "Xdebug table".</p> </div> <a name="xdebug_get_headers"></a> <hr class="light" /> <div class="name"> <span class="type">array</span> xdebug_get_headers() </div> <div class="short-description"> Returns all the headers as set by calls to PHP's header() function </div> <div class="version"> Introduced in version 2.1 </div> <div class="description"> <p>Returns all the headers that are set with PHP's header() function, or any other header set internally within PHP (such as through setcookie()), as an array. </p> <div class="example"> <strong>Example:</strong> <br /> <br /> <code><span style="color:#000000;"><span style="color:#0000bb;"><?php<br /> header</span><span style="color:#007700;">( </span><span style="color:#dd0000;">"X-Test"</span><span style="color:#007700;">, </span><span style="color:#dd0000;">"Testing" </span><span style="color:#007700;">);<br /> </span><span style="color:#0000bb;">setcookie</span><span style="color:#007700;">( </span><span style="color:#dd0000;">"TestCookie"</span><span style="color:#007700;">, </span><span style="color:#dd0000;">"test-value" </span><span style="color:#007700;">);<br /> </span><span style="color:#0000bb;">var_dump</span><span style="color:#007700;">( </span><span style="color:#0000bb;">xdebug_get_headers</span><span style="color:#007700;">() );<br /> </span><span style="color:#0000bb;">?><br /> </span><br /> </span></code> </div> <div class="example-returns"> <strong>Returns:</strong> <br /> <br /> <pre>array(2) { [0]=> string(6) "X-Test" [1]=> string(33) "Set-Cookie: TestCookie=test-value" }</pre> </div> </div> <a name="xdebug_is_enabled"></a> <hr class="light" /> <div class="name"> <span class="type">bool</span> xdebug_is_enabled() </div> <div class="short-description"> Returns whether stack traces are enabled </div> <div class="description"> <p>Return whether stack traces would be shown in case of an error or not.</p> </div> <a name="xdebug_memory_usage"></a> <hr class="light" /> <div class="name"> <span class="type">int</span> xdebug_memory_usage() </div> <div class="short-description"> Returns the current memory usage </div> <div class="description"> <p>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.</p> </div> <a name="xdebug_peak_memory_usage"></a> <hr class="light" /> <div class="name"> <span class="type">int</span> xdebug_peak_memory_usage() </div> <div class="short-description"> Returns the peak memory usage </div> <div class="description"> <p>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.</p> </div> <a name="xdebug_start_error_collection"></a> <hr class="light" /> <div class="name"> <span class="type">void</span> xdebug_start_error_collection() </div> <div class="short-description"> Starts recording all notices, warnings and errors and prevents their display </div> <div class="version"> Introduced in version 2.1 </div> <div class="description"> <p>When this function is executed, Xdebug will cause PHP not to display any notices, warnings or errors. Instead, they are formatted according to Xdebug's normal error formatting rules (ie, the error table with the red exclamation mark) and then stored in a buffer. This will continue until you call <a href="/misc/goto?guid=4959221769495752977">xdebug_stop_error_collection()</a>. </p> <p>This buffer's contents can be retrieved by calling <a href="/misc/goto?guid=4959221769583632833">xdebug_get_collected_errors()</a> and then subsequently displayed. This is really useful if you want to prevent Xdebug's powerful error reporting features from destroying your layout. </p> </div> <a name="xdebug_stop_error_collection"></a> <hr class="light" /> <div class="name"> <span class="type">void</span> xdebug_stop_error_collection() </div> <div class="short-description"> Stops recording of all notices, warnings and errors as started by <a href="/misc/goto?guid=4959221769409368628">xdebug_start_error_collection()</a> </div> <div class="version"> Introduced in version 2.1 </div> <div class="description"> <p>When this function is executed, error collection as started by <a href="/misc/goto?guid=4959221769409368628">xdebug_start_error_collection()</a> is aborted. The errors stored in the collection buffer are not deleted and still available to be fetched through <a href="/misc/goto?guid=4959221769583632833">xdebug_get_collected_errors()</a>.</p> </div> <a name="xdebug_time_index"></a> <hr class="light" /> <div class="name"> <span class="type">float</span> xdebug_time_index() </div> <div class="short-description"> Returns the current time index </div> <div class="description"> <p>Returns the current time index since the starting of the script in seconds. </p> <div class="example"> <strong>Example:</strong> <br /> <br /> <code><span style="color:#000000;"><span style="color:#0000bb;"><?php<br /> </span><span style="color:#007700;">echo </span><span style="color:#0000bb;">xdebug_time_index</span><span style="color:#007700;">(), </span><span style="color:#dd0000;">"\n"</span><span style="color:#007700;">;<br /> for (</span><span style="color:#0000bb;">$i </span><span style="color:#007700;">= </span><span style="color:#0000bb;">0</span><span style="color:#007700;">; </span><span style="color:#0000bb;">$i </span><span style="color:#007700;">< </span><span style="color:#0000bb;">250000</span><span style="color:#007700;">; </span><span style="color:#0000bb;">$i</span><span style="color:#007700;">++)<br /> {<br /> </span><span style="color:#ff8000;">// do nothing<br /> </span><span style="color:#007700;">}<br /> echo </span><span style="color:#0000bb;">xdebug_time_index</span><span style="color:#007700;">(), </span><span style="color:#dd0000;">"\n"</span><span style="color:#007700;">;<br /> </span><span style="color:#0000bb;">?><br /> </span><br /> </span></code> </div> <div class="example-returns"> <strong>Returns:</strong> <br /> <br /> <pre>0.00038003921508789 0.76580691337585</pre> </div> </div> </div> </span>