<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >debug_backtrace</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="Error Handling and Logging Functions" HREF="ref.errorfunc.html"><LINK REL="PREVIOUS" TITLE="Error Handling and Logging Functions" HREF="ref.errorfunc.html"><LINK REL="NEXT" TITLE="debug_print_backtrace" HREF="function.debug-print-backtrace.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="ref.errorfunc.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.debug-print-backtrace.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.debug-backtrace" ></A >debug_backtrace</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN47304" ></A ><P > (PHP 4 >= 4.3.0, PHP 5)</P >debug_backtrace -- Generates a backtrace</DIV ><DIV CLASS="refsect1" ><A NAME="AEN47307" ></A ><H2 >说明</H2 >array <B CLASS="methodname" >debug_backtrace</B > ( void )<BR ></BR ><P > <B CLASS="function" >debug_backtrace()</B > generates a PHP backtrace. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN47315" ></A ><H2 >返回值</H2 ><P > Returns an associative <A HREF="language.types.array.html" ><B CLASS="type" >array</B ></A >. The possible returned elements are as follows: </P ><P > <DIV CLASS="table" ><A NAME="AEN47320" ></A ><P ><B >表 1. Possible returned elements from <B CLASS="function" >debug_backtrace()</B ></B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Name</TH ><TH >Type</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD >function</TD ><TD ><A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A ></TD ><TD > The current function name. See also <A HREF="language.constants.predefined.html" >__FUNCTION__</A >. </TD ></TR ><TR ><TD >line</TD ><TD ><A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A ></TD ><TD > The current line number. See also <A HREF="language.constants.predefined.html" >__LINE__</A >. </TD ></TR ><TR ><TD >file</TD ><TD ><A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A ></TD ><TD > The current file name. See also <A HREF="language.constants.predefined.html" >__FILE__</A >. </TD ></TR ><TR ><TD >class</TD ><TD ><A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A ></TD ><TD > The current <A HREF="language.oop.html" >class</A > name. See also <A HREF="language.constants.predefined.html" >__CLASS__</A > </TD ></TR ><TR ><TD >object</TD ><TD ><A HREF="language.types.object.html" ><B CLASS="type" >object</B ></A ></TD ><TD > The current <A HREF="language.oop.html" >object</A >. </TD ></TR ><TR ><TD >type</TD ><TD ><A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A ></TD ><TD > The current call type. If a method call, "->" is returned. If a static method call, "::" is returned. If a function call, nothing is returned. </TD ></TR ><TR ><TD >args</TD ><TD ><A HREF="language.types.array.html" ><B CLASS="type" >array</B ></A ></TD ><TD > If inside a function, this lists the functions arguments. If inside an included file, this lists the included file name(s). </TD ></TR ></TBODY ></TABLE ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN47371" ></A ><H2 >更新日志</H2 ><P > <DIV CLASS="informaltable" ><P ></P ><A NAME="AEN47374" ></A ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH >版本</TH ><TH >说明</TH ></TR ></THEAD ><TBODY ><TR ><TD >5.1.1</TD ><TD > Added the current <A HREF="language.types.object.html" ><B CLASS="type" >object</B ></A > as a possible return element. </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN47385" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN47388" ></A ><P ><B >例 1. <B CLASS="function" >debug_backtrace()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">// filename: a.php<br /><br /></font><font color="#007700">function </font><font color="#0000BB">a_test</font><font color="#007700">(</font><font color="#0000BB">$str</font><font color="#007700">)<br />{<br /> echo </font><font color="#DD0000">"</font><font color="#007700">\n</font><font color="#DD0000">Hi: $str"</font><font color="#007700">;<br /> </font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">debug_backtrace</font><font color="#007700">());<br />}<br /><br /></font><font color="#0000BB">a_test</font><font color="#007700">(</font><font color="#DD0000">'friend'</font><font color="#007700">);<br /></font><font color="#0000BB">?><br /></font><br /><font color="#0000BB"><?php<br /></font><font color="#FF8000">// filename: b.php<br /></font><font color="#007700">include_once </font><font color="#DD0000">'/tmp/a.php'</font><font color="#007700">;<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P > Results similar to the following when executing <TT CLASS="filename" >/tmp/b.php</TT >: </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >Hi: friend array(2) { [0]=> array(4) { ["file"] => string(10) "/tmp/a.php" ["line"] => int(10) ["function"] => string(6) "a_test" ["args"]=> array(1) { [0] => &string(6) "friend" } } [1]=> array(4) { ["file"] => string(10) "/tmp/b.php" ["line"] => int(2) ["args"] => array(1) { [0] => string(10) "/tmp/a.php" } ["function"] => string(12) "include_once" } }</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN47395" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.trigger-error.html" ><B CLASS="function" >trigger_error()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.debug-print-backtrace.html" ><B CLASS="function" >debug_print_backtrace()</B ></A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="ref.errorfunc.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.debug-print-backtrace.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Error Handling and Logging Functions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.errorfunc.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >debug_print_backtrace</TD ></TR ></TABLE ></DIV ></BODY ></HTML >