<HTML ><HEAD ><TITLE >Execution Information</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Printing Information" HREF="zend.printing.html"><LINK REL="PREVIOUS" TITLE="Including Output in phpinfo" HREF="zend.printing.phpinfo.html"><LINK REL="NEXT" TITLE="Startup and Shutdown Functions" HREF="zend.startup-and-shutdown.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="section" 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 Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="zend.printing.phpinfo.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 36. Printing Information</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="zend.startup-and-shutdown.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="zend.printing.execution" ></A >Execution Information</H1 ><P > You can also print execution information, such as the current file being executed. The name of the function currently being executed can be retrieved using the function <B CLASS="function" >get_active_function_name()</B >. This function returns a pointer to the function name and doesn't accept any arguments. To retrieve the name of the file currently being executed, use <B CLASS="function" >zend_get_executed_filename()</B >. This function accesses the executor globals, which are passed to it using the <TT CLASS="literal" >TSRMLS_C</TT > macro. The executor globals are automatically available to every function that's called directly by Zend (they're part of the <TT CLASS="literal" >INTERNAL_FUNCTION_PARAMETERS</TT > described earlier in this chapter). If you want to access the executor globals in another function that doesn't have them available automatically, call the macro <TT CLASS="literal" >TSRMLS_FETCH()</TT > once in that function; this will introduce them to your local scope. </P ><P > Finally, the line number currently being executed can be retrieved using the function <B CLASS="function" >zend_get_executed_lineno()</B >. This function also requires the executor globals as arguments. For examples of these functions, see <A HREF="zend.printing.execution.html#example.exec-info" >Example 36-2</A >. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="example.exec-info" ></A ><P ><B >Example 36-2. Printing execution information.</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" >zend_printf("The name of the current function is %s<br>", get_active_function_name(TSRMLS_C)); zend_printf("The file currently executed is %s<br>", zend_get_executed_filename(TSRMLS_C)); zend_printf("The current line being executed is %i<br>", zend_get_executed_lineno(TSRMLS_C));</PRE ></TD ></TR ></TABLE ><P ><IMG SRC="figures/Extending_Zend_9_execution_info.png"></P ></DIV ></TD ></TR ></TABLE ></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="zend.printing.phpinfo.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="zend.startup-and-shutdown.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Including Output in <A HREF="function.phpinfo.html" ><B CLASS="function" >phpinfo()</B ></A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="zend.printing.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Startup and Shutdown Functions</TD ></TR ></TABLE ></DIV ></BODY ></HTML >