Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5701

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Specify a function to capture and/or process output from a runkit sandbox</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.runkit-return-value-used.html">runkit_return_value_used</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.runkit-superglobals.html">runkit_superglobals</a></div>
 <div class="up"><a href="ref.runkit.html">runkit Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.runkit-sandbox-output-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">runkit_sandbox_output_handler</h1>
  <p class="verinfo">(PECL runkit &gt;= 0.7.0)</p><p class="refpurpose"><span class="refname">runkit_sandbox_output_handler</span> &mdash; <span class="dc-title">
   Specify a function to capture and/or process output from a runkit sandbox
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.runkit-sandbox-output-handler-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>runkit_sandbox_output_handler</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$sandbox</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$callback</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Ordinarily, anything output (such as with  <span class="function"><a href="function.echo.html" class="function">echo</a></span>
   or  <span class="function"><a href="function.print.html" class="function">print</a></span>) will be output as though it were printed
   from the parent&#039;s scope.  Using  <span class="function"><strong>runkit_sandbox_output_handler()</strong></span>
   however, output generated by the sandbox (including errors), can be captured
   by a function outside of the sandbox.
  </p>

  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">Sandbox support (required for
 <span class="function"><a href="function.runkit-lint.html" class="function">runkit_lint()</a></span>,  <span class="function"><a href="function.runkit-lint-file.html" class="function">runkit_lint_file()</a></span>,
and the <strong class="classname">Runkit_Sandbox</strong> class) is only available as of
PHP 5.1.0 or specially patched versions of PHP 5.0, and requires that thread
safety be enabled.
See the <var class="filename">README</var> file included in the runkit package for
more information.</span></p></blockquote>

  <blockquote class="note"><p><strong class="note">Note</strong>: 
    <strong>Deprecated</strong><br />
    <p class="para">
      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" class="link">Runkit_Sandbox</a> class definition page.
    </p>
  </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.runkit-sandbox-output-handler-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">sandbox</code></em></span>
     <dd>

      <p class="para">
       Object instance of Runkit_Sandbox class on which to set output handling.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">callback</code></em></span>
     <dd>

      <p class="para">
       Name of a function which expects one parameter.
       Output generated by <em><code class="parameter">sandbox</code></em> 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>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.runkit-sandbox-output-handler-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the name of the previously defined output handler callback, or
   <strong><code>FALSE</code></strong> if no handler was previously defined.
  </p>
 </div>


 
 <div class="refsect1 examples" id="refsect1-function.runkit-sandbox-output-handler-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-545">
    <p><strong>Example #1 Feeding output to a variable</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">capture_output</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'sandbox_output'</span><span style="color: #007700">]&nbsp;.=&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$sandbox_output&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$php&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Runkit_Sandbox</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">runkit_sandbox_output_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$php</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'capture_output'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$php</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">echo</span><span style="color: #007700">(</span><span style="color: #DD0000">"Hello\n"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$php</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">eval</span><span style="color: #007700">(</span><span style="color: #DD0000">'var_dump("Excuse&nbsp;me");'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$php</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">die</span><span style="color: #007700">(</span><span style="color: #DD0000">"I&nbsp;lost&nbsp;myself."</span><span style="color: #007700">);<br />unset(</span><span style="color: #0000BB">$php</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Sandbox&nbsp;Complete\n\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$sandbox_output</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Sandbox Complete

Hello
string(9) &quot;Excuse me&quot;
I lost myself.
</pre></div>
    </div>
   </div>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.runkit-return-value-used.html">runkit_return_value_used</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.runkit-superglobals.html">runkit_superglobals</a></div>
 <div class="up"><a href="ref.runkit.html">runkit Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>