⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runkit.sandbox.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</code></div>   </div>  </div>  <p class="para">The above example will output:</p>  <div class="example-contents"><pre><div class="cdata"><pre>barbarbazbool(false)</pre></div>  </pre></div> </div> <div class="refsect1 functions">  <h3 class="title">Calling PHP Functions</h3>  <p class="para">   Any function defined within the sandbox may be called as   a method on the sandbox object.  This also includes a few   pseudo-function language constructs:  <a href="function.eval.html" class="function">eval()</a>,   <b>include()</b>, <b>include_once()</b>,   <b>require()</b>, <b>require_once()</b>,   <a href="function.echo.html" class="function">echo()</a>, <a href="function.print.html" class="function">print()</a>,   <a href="function.die.html" class="function">die()</a>, and <a href="function.exit.html" class="function">exit()</a>.  </p>  <div class="example">   <p><b>Example #3 Calling sandbox functions</b></p>   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$sandbox&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Runkit_Sandbox</span><span style="color: #007700">();<br /><br />echo&nbsp;</span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'a'</span><span style="color: #007700">,</span><span style="color: #DD0000">'f'</span><span style="color: #007700">,</span><span style="color: #DD0000">'abc'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>   </div>  </div>  <p class="para">The above example will output:</p>  <div class="example-contents"><pre><div class="cdata"><pre>fbc</pre></div>  </pre></div>  <p class="para">   When passing arguments to a sandbox function, the arguments   are taken from the outer instance of PHP.  If you wish to pass   arguments from the sandbox&#039;s scope, be sure to access them as   properties of the sandbox object as illustrated above.  </p>  <div class="example">   <p><b>Example #4 Passing arguments to sandbox functions</b></p>   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$sandbox&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Runkit_Sandbox</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'baz'</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'a'</span><span style="color: #007700">,</span><span style="color: #0000BB">$foo</span><span style="color: #007700">,</span><span style="color: #DD0000">'a'</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'a'</span><span style="color: #007700">,</span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">foo</span><span style="color: #007700">,</span><span style="color: #DD0000">'a'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>   </div>  </div>  <p class="para">The above example will output:</p>  <div class="example-contents"><pre><div class="cdata"><pre>barbaz</pre></div>  </pre></div> </div> <div class="refsect1 settings">  <h3 class="title">Changing Sandbox Settings</h3>  <p class="para">   As of runkit version 0.5, certain Sandbox settings may   be modified on the fly using ArrayAccess syntax.   Some settings, such as <i><tt class="parameter">active</tt></i>   are read-only and meant to provide status information.   Other settings, such as <i><tt class="parameter">output_handler</tt></i>   may be set and read much like a normal array offset.   Future settings may be write-only, however no such   settings currently exist.  </p>  <p class="para">   <table border="5">    <caption><b>Sandbox Settings / Status Indicators</b></caption>    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Setting</th>       <th colspan="1">Type</th>       <th colspan="1">Purpose</th>       <th colspan="1">Default</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>active</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a> (Read Only)</td>       <td colspan="1" rowspan="1" align="left">        <b><tt>TRUE</tt></b> if the Sandbox is still in a usable state,        <b><tt>FALSE</tt></b> if the request is in bailout due to a        call to die(), exit(), or because of a fatal        error condition.       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> (Initial)</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>output_handler</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.pseudo-types.html#language.types.callback" class="type Callback">Callback</a></td>       <td colspan="1" rowspan="1" align="left">        When set to a valid callback, all output generated        by the Sandbox instance will be processed through        the named function.        Sandbox output handlers follow the same calling        conventions as the system-wide output handler.       </td>       <td colspan="1" rowspan="1" align="left">None</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_access</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox use instances of the        <b class="classname">Runkit_Sandbox_Parent</b> class?        Must be enabled for other        <b class="classname">Runkit_Sandbox_Parent</b>        related settings to work.       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_read</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox read variables in its parent&#039;s context?       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_write</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox modify variables in its parent&#039;s context?       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_eval</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox evaluate arbitrary code in its        parent&#039;s context? <em class="emphasis">DANGEROUS</em>       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_include</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox include php code files in its        parent&#039;s context? <em class="emphasis">DANGEROUS</em>       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_echo</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox echo data in its parent&#039;s context        effectively bypassing its own output_handler?       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_call</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox call functions in its        parent&#039;s context?       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_die</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.boolean.html" class="type Boolean">Boolean</a></td>       <td colspan="1" rowspan="1" align="left">        May the sandbox kill its own parent? (And thus itself)       </td>       <td colspan="1" rowspan="1" align="left"><b><tt>FALSE</tt></b></td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_scope</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.integer.html" class="type Integer">Integer</a></td>       <td colspan="1" rowspan="1" align="left">        What scope will parental property access look at?        0 == Global scope, 1 == Calling scope,        2 == Scope preceeding calling scope,        3 == The scope before that, etc..., etc...       </td>       <td colspan="1" rowspan="1" align="left"><i>0</i> (Global)</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left"><i>parent_scope</i></td>       <td colspan="1" rowspan="1" align="left"><a href="language.types.string.html" class="type String">String</a></td>       <td colspan="1" rowspan="1" align="left">        When <i>parent_scope</i> is set to        a string value, it refers to a named array variable        in the global scope.  If the named variable does not        exist at the time of access it will be created as an        empty array.  If the variable exists but it not an array,        a dummy array will be created containing a reference        to the named global variable.       </td>       <td class="empty">&nbsp;</td>      </tr>     </tbody>    </colgroup>   </table>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.runkit.html">runkit Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="runkit.sandbox-parent.html">Runkit_Sandbox_Parent</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -