<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="plugins.writing.html" accesskey="P">Prev</a></td><td width="50%" align="center" valign="bottom">Chapter 16. Extending Smarty With Plugins</td><td width="25%" align="right" valign="bottom"><a href="plugins.modifiers.html" accesskey="N">Next</a></td></tr></table> # Template Functions[模板函數] > void smarty_function_name($params, &$smarty); array $params; object &$smarty; All attributes passed to template functions from the template are contained in the $params as an associative array. The output (return value) of the function will be substituted in place of the function tag in the template, eg the {fetch} function. Alternatively, the function can simply perform some other task without any output, eg the {assign} function. If the function needs to assign some variables to the template or use some other Smarty-provided functionality, it can use the supplied $smarty object to do so eg $smarty->foo(). 模板傳遞給模板函數的所有屬性都包含在關聯數組$params中。 在模板中,函數的輸出內容(返回值)在原位置用函數標簽代替,例如{fetch}函數。作為另一種選擇,函數也可以單純地用來做些非輸出內容的任務,如{assign}函數。 如果函數需要分配(俗話說的賦值)一些變量給模板或者使用Smarty提供的一些函數,可以通過$smarty對象實現,如$smarty->foo()。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><a name="AEN4161" id="AEN4161"/><b>Example 16.1. function plugin with output</b><br/><strong>例16-1.帶輸出的函數插件</strong><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">&lt;?php/* * Smarty plugin * ------------------------------------------------------------- * File: function.eightball.php * Type: function * Name: eightball * Purpose: outputs a random magic answer * ------------------------------------------------------------- */function smarty_function_eightball($params, $smarty){ $answers = array('Yes', 'No', 'No way', 'Outlook not so good', 'Ask again soon', 'Maybe in your reality'); $result = array_rand($answers); return $answers[$result];}?&gt;which can be used in the template as:Question: Will we ever have time travel?Answer: {eightball}. </pre></td></tr></table></div></td></tr></table> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><b>Example 16.2. function plugin without output</b><br/><strong>例16-2.不帶輸出的函數</strong><strong>插件</strong><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td>&lt;?php<br/> /*<br/>* Smarty plugin<br/>* -------------------------------------------------------------<br/>* File: function.assign.php<br/>* Type: function<br/>* Name: assign<br/>* Purpose: assign a value to a template variable<br/>* -------------------------------------------------------------<br/>*/<br/>function smarty_function_assign($params, $smarty)<br/>{<br/>if (empty($params['var'])) {<br/>$smarty-&gt;triggerError("assign: missing 'var' parameter");<br/>return;<br/>}<br/>if (!in_array('value', array_keys($params))) {<br/>$smarty-&gt;triggerError("assign: missing 'value' parameter");<br/>return;<br/>}<br/>$smarty-&gt;assign($params['var'], $params['value']);<br/>}<br/>?&gt;</td></tr></table><p> 參見<a href="api.register.function.html">registerPlugin()</a>、<a href="api.unregister.function.html">unregisterPlugin()</a>。</p></div></td></tr></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="plugins.writing.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="plugins.modifiers.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Writing Plugins<br/> 編寫插件</td><td width="34%" align="center" valign="top"><a href="plugins.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Modifiers<br/> 調節器插件</td></tr></table>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看