Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 9428

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>runkit_sandbox_output_handler</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="runkit Functions"
HREF="ref.runkit.html"><LINK
REL="PREVIOUS"
TITLE="runkit_return_value_used"
HREF="function.runkit-return-value-used.html"><LINK
REL="NEXT"
TITLE="runkit_superglobals"
HREF="function.runkit-superglobals.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="function.runkit-return-value-used.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.runkit-superglobals.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.runkit-sandbox-output-handler"
></A
>runkit_sandbox_output_handler</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN199799"
></A
><P
>    (PECL)</P
>runkit_sandbox_output_handler&nbsp;--&nbsp;
   Specify a function to capture and/or process output from a runkit sandbox
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN199802"
></A
><H2
>说明</H2
>mixed <B
CLASS="methodname"
>runkit_sandbox_output_handler</B
> ( object sandbox [, mixed callback] )<BR
></BR
><P
>&#13;   Ordinarily, anything output (such as with <A
HREF="function.echo.html"
><B
CLASS="function"
>echo()</B
></A
>
   or <A
HREF="function.print.html"
><B
CLASS="function"
>print()</B
></A
>) will be output as though it were printed
   from the parent's scope.  Using <B
CLASS="function"
>runkit_sandbox_output_handler()</B
>
   however, output generated by the sandbox (including errors), can be captured
   by a function outside of the sandbox.
  </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>对沙盒的支持(是函数
<A
HREF="function.runkit-lint.html"
><B
CLASS="function"
>runkit_lint()</B
></A
>、<A
HREF="function.runkit-lint-file.html"
><B
CLASS="function"
>runkit_lint_file()</B
></A
>
和 Runkit_Sandbox 类所必须的)仅在 PHP 5.1 中,或在加过特别补丁的 PHP 5.0
中可用,并需要启用线程安全。请阅读 runkit 包中的 README 文件以了解更多信息。
</P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Deprecated: </B
>
      As of runkit version 0.5, this function is deprecated and is scheduled to
      be removed from the package prior to a 1.0 release.  The output handler for
      a given Runkit_Sandbox instance may be read/set using the array offset syntax
      shown on the <A
HREF="runkit.sandbox.html"
>Runkit_Sandbox</A
> class definition page.
    </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN199825"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>sandbox</CODE
></DT
><DD
><P
>&#13;       Object instance of Runkit_Sandbox class on which to set output handling.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>callback</CODE
></DT
><DD
><P
>&#13;       Name of a function which expects one parameter.
       Output generated by <CODE
CLASS="parameter"
>sandbox</CODE
> will be passed
       to this callback.  Anything returned by the callback will be displayed
       normally.  If this parameter is not passed then output handling will not be changed.
       If a non-truth value is passed, output handling will be disabled and will revert to
       direct display.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN199840"
></A
><H2
>返回值</H2
><P
>&#13;   Returns the name of the previously defined output handler callback, or
   <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if no handler was previously defined.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN199844"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN199847"
></A
><P
><B
>例 1. Feeding output to a variable</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">function </font><font color="#0000BB">capture_output</font><font color="#007700">(</font><font color="#0000BB">$str</font><font color="#007700">) {<br />&nbsp;&nbsp;</font><font color="#0000BB">$GLOBALS</font><font color="#007700">[</font><font color="#DD0000">'sandbox_output'</font><font color="#007700">] .= </font><font color="#0000BB">$str</font><font color="#007700">;<br /><br />&nbsp;&nbsp;return </font><font color="#DD0000">''</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">$sandbox_output </font><font color="#007700">= </font><font color="#DD0000">''</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$php </font><font color="#007700">= new </font><font color="#0000BB">Runkit_Sandbox</font><font color="#007700">();<br /></font><font color="#0000BB">runkit_sandbox_output_handler</font><font color="#007700">(</font><font color="#0000BB">$php</font><font color="#007700">, </font><font color="#DD0000">'capture_output'</font><font color="#007700">);<br /></font><font color="#0000BB">$php</font><font color="#007700">-&gt;</font><font color="#0000BB">echo</font><font color="#007700">(</font><font color="#DD0000">"Hello\n"</font><font color="#007700">);<br /></font><font color="#0000BB">$php</font><font color="#007700">-&gt;</font><font color="#0000BB">eval</font><font color="#007700">(</font><font color="#DD0000">'var_dump("Excuse me");'</font><font color="#007700">);<br /></font><font color="#0000BB">$php</font><font color="#007700">-&gt;</font><font color="#0000BB">die</font><font color="#007700">(</font><font color="#DD0000">"I lost myself."</font><font color="#007700">);<br />unset(</font><font color="#0000BB">$php</font><font color="#007700">);<br /><br />echo </font><font color="#DD0000">"Sandbox Complete\n\n"</font><font color="#007700">;<br />echo </font><font color="#0000BB">$sandbox_output</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Sandbox Complete

Hello
string(9) "Excuse me"
I lost myself.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </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="function.runkit-return-value-used.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.runkit-superglobals.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>runkit_return_value_used</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.runkit.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>runkit_superglobals</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>