<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                <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="language.variables.html">Prev</a></td><td width="50%" align="center" valign="bottom">Chapter 4. Variables[第四章.變量]</td><td width="25%" align="right" valign="bottom"><a href="language.variables.scopes.html">Next</a></td></tr></table> # [Variables assigned from PHP]()[**從PHP分配的變量**] **Table of Contents[內容列表]**[Associative arrays](#)[關聯數組][Array indexes](#)[數組下標][Objects](#)[對象] Variables that are assigned from PHP are referenced by preceding them with a dollar sign $. 調用從PHP分配的變量需在前加"$"符號(譯注:同php一樣)。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><a name="AEN242" id="AEN242"/> <b>Example 4.2. Assigned variables<br/> 例 4-2.分配的變量</b> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><p> PHP code:<br/> &lt;?php<br/> $smarty = new Smarty();<br/> $smarty-&gt;assign('firstname', 'Doug');<br/> $smarty-&gt;assign('lastname', 'Evans');<br/> $smarty-&gt;assign('meetingPlace', 'New York');<br/> $smarty-&gt;display('index.tpl');<br/> ?&gt;<br/><br/> index.tpl source:</p> <p>Hello {$firstname} {$lastname}, glad to see you can make it.<br/> &lt;br /&gt;<br/> {* this will not work as $variables are case sensitive *} {* 下行讀取不到變量,因為變量區分大小寫字臺 *} <br/> This weeks meeting is in {$meetingplace}.<br/> {* this will work *}<br/> This weeks meeting is in {$meetingPlace}.<br/><br/> This above would output:<br/> Hello Doug Evans, glad to see you can make it.<br/> &lt;br /&gt;<br/> This weeks meeting is in .<br/> This weeks meeting is in New York.</p></td></tr></table></div></td></tr></table> ### Associative arrays[關聯數組] You can also reference associative array variables that are assigned from PHP by specifying the key after the '.' (period) symbol. 你也可以通過句號“.”后接數組鍵的方式來引用從php分配的關聯數組變量。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><b>Example 4-3. accessing associative array variables</b> <br/><strong>例4.3.訪問關聯數組變量 </strong> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">index.php:&#13; &#13; $smarty = new Smarty;&#13; $smarty-&gt;assign('Contacts',&#13; array('fax' =&gt; '555-222-9876',&#13; 'email' =&gt; 'zaphod@slartibartfast.com',&#13; 'phone' =&gt; array('home' =&gt; '555-444-3333',&#13; 'cell' =&gt; '555-111-1234')));&#13; $smarty-&gt;display('index.tpl');&#13; &#13; index.tpl:&#13; &#13; {$Contacts.fax}&lt;br&gt;&#13; {$Contacts.email}&lt;br&gt;&#13; {* you can print arrays of arrays as well *} {* 同樣可以用于多維數組 *}&#13; {$Contacts.phone.home}&lt;br&gt;&#13; {$Contacts.phone.cell}&lt;br&gt;&#13; &#13; OUTPUT:&#13; &#13; 555-222-9876&lt;br&gt;&#13; zaphod@slartibartfast.com&lt;br&gt;&#13; 555-444-3333&lt;br&gt;&#13; 555-111-1234&lt;br&gt;</pre> </td> </tr></table></div></td> </tr></table> ### Array indexes[數組索引] You can reference arrays by their index, much like native PHP syntax. 你也可以使用php原生語法風格引用數組索引。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"> <p><b>Example 4-4. accessing arrays by index</b> <br/><strong>例4.4.</strong><strong>通過索引訪問數組 </strong> </p> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><p>&lt;?php<br/> $smarty-&gt;assign('Contacts', array(<br/> '555-222-9876',<br/> 'zaphod@slartibartfast.example.com',<br/> array('555-444-3333',<br/> '555-111-1234')<br/> ));<br/> $smarty-&gt;display('index.tpl');<br/> ?&gt;<br/><br/> index.tpl source:<br/> {$Contacts[0]}&lt;br /&gt;<br/> {$Contacts[1]}&lt;br /&gt;<br/> {* you can print arrays of arrays as well *}<br/> {$Contacts[2][0]}&lt;br /&gt;<br/> {$Contacts[2][1]}&lt;br /&gt;</p> <p>This will output:<br/> 555-222-9876&lt;br /&gt;<br/> zaphod@slartibartfast.example.com&lt;br /&gt;<br/> 555-444-3333&lt;br /&gt;<br/> 555-111-1234&lt;br /&gt;</p></td> </tr></table></div></td> </tr></table> ### Objects[對象] Properties of objects assigned from PHP can be referenced by specifying the property name after the '->' symbol. 可以通過‘->‘符號后接指定屬性名的方式訪問php分配的對象屬性(這不是php訪問對象屬性的方法嘛,直說嘛:))。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"><b>Example 4-5. accessing object properties</b> <br/><strong>例4.5.訪問對象屬性</strong> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">name: {$person-&gt;name}&lt;br&gt;&#13; email: {$person-&gt;email}&lt;br&gt;&#13; &#13; OUTPUT:&#13; &#13; name: Zaphod Beeblebrox&lt;br&gt;&#13; email: zaphod@slartibartfast.com&lt;br&gt;</pre> </td> </tr></table></div></td> </tr></table> <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="language.variables.html">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html">Home</a></td><td width="33%" align="right" valign="top"><a href="language.variables.scopes.html">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Variables<br/> 變量</td> <td width="34%" align="center" valign="top"><a href="smarty.for.designers.html">Up</a></td> <td width="33%" align="right" valign="top">Variable scopes<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>

                              哎呀哎呀视频在线观看