Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

Menyertakan Vars dalam Tanda Kutip Ganda

  • Smarty akan mengenali variabel yang ditempati yang disertakan dalam "tanda kutip ganda" selama nama variabel hanya berisi angka, huruf, garis bawah, dan kurung[]. Lihat penamaan untuk lebih jelasnya.

  • Dengan karakter lainnya, contohnya .titik atau $object>referensi, maka variabel harus dikelilingi oleh `tanda kutip mundur`.

  • Anda tidak bisa menyertakan pengubah, ia harus selalu diterapkan di luar tanda kutip.

Teladan 3-5. Contoh sintaks

{func var="test $foo test"}       <-- melihat $foo
{func var="test $foo_bar test"}   <-- melihat $foo_bar
{func var="test $foo[0] test"}    <-- melihat $foo[0]
{func var="test $foo[bar] test"}  <-- melihat $foo[bar]
{func var="test $foo.bar test"}   <-- melihat $foo (bukan $foo.bar)
{func var="test `$foo.bar` test"} <-- melihat $foo.bar
{func var="test `$foo.bar` test"|escape} <-- pengubah di luar tanda kutip!

Teladan 3-6. Contoh praktis

{* akan mengganti $tpl_name dengan nilai *}
{include file="subdir/$tpl_name.tpl"}

{* tidak mengganti $tpl_name *}
{include file='subdir/$tpl_name.tpl'} <--

{* harus mempunyai tanda kutip mundur karena berisi sebuah . *}
{cycle values="one,two,`$smarty.config.myval`"}

{*  sama seperti $module['contact'].'.tpl' dalam naskah php
{include file="`$module.contact`.tpl"}

{*  sama seperti $module[$view].'.tpl' dalam naskah php
{include file="$module.$view.tpl"}

Lihat juga escape.

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 15 plus 3? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk