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

ダブルクォート内に埋め込まれた変数

  • Smarty が "ダブルクォート" で囲まれた内容の中から 割り当てられた 変数 として認識するのは、変数名が数字・文字・_(アンダースコア)・[](ブラケット) のみで構成されているもののみです。詳細は 名前の付けかた を参照ください。

  • その他の文字、たとえば .(ピリオド)や $object>reference(オブジェクト参照)を含む場合は、 その変数を `バッククォート` で囲む必要があります。

  • 修飾子 を埋め込むことはできず、 常にクォートの外で適用する必要があります。

Example 3.5. 構文の例


{func var="test $foo test"}       <-- $foo を参照します
{func var="test $foo_bar test"}   <-- $foo_bar を参照します
{func var="test $foo[0] test"}    <-- $foo[0] を参照します
{func var="test $foo[bar] test"}  <-- $foo[bar] を参照します
{func var="test $foo.bar test"}   <-- $foo (not $foo.bar) を参照します
{func var="test `$foo.bar` test"} <-- $foo.bar を参照します
{func var="test `$foo.bar` test"|escape} <-- 修飾子はクォートの外で!

  

Example 3.6. 実用例


{* $tpl_name を値で置き換えます *}
{include file="subdir/$tpl_name.tpl"}

{* $tpl_name を置き換えません *}
{include file='subdir/$tpl_name.tpl'} <--

{* . を含むのでバッククォートで囲む必要があります *}
{cycle values="one,two,`$smarty.config.myval`"}

{* php スクリプトでの $module['contact'].'.tpl' と同じです
{include file="`$module.contact`.tpl"}

{* php スクリプトでの $module[$view].'.tpl' と同じです
{include file="`$module.$view`.tpl"}

  

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 1 plus 18? (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