Get Smarty

Donate

Paypal

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:

Sites Using Smarty

Advertisement

escape

escape dipakai untuk mengkodekan atau mengubah variabel ke contohnya html, url, tanda kutip tunggal, heksa, heksentitas, javascript dan mail. Standarnya html.

Posisi ParameterTipeDiperlukanNilai yang MungkinDefaultDeskripsi
1stringTidakhtml, htmlall, url, urlpathinfo, quotes, hex, hexentity, javascript, mail htmlIni adalah format escape yang digunakan.
2stringTidakISO-8859-1, UTF-8, dan setiap karakter yang didukung oleh htmlentities() ISO-8859-1Set karakter yang semuanya dikirimkan ke htmlentities().

Teladan 5-10. escape

assign(\'articleTitle\', "\'Stiff Opposition Expected to Casketless Funeral Plan\'" ); $smarty->assign(\'EmailAddress\',\'smarty@example.com\'); ?>'); ?>

Ini adalah contoh baris template escape diikuti oleh output

{$articleTitle}
'Stiff Opposition Expected to Casketless Funeral Plan'

{$articleTitle|escape}
'Stiff Opposition Expected to Casketless Funeral Plan'

{$articleTitle|escape:'html'}    {* escapes  & " ' < > *}
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;

{$articleTitle|escape:'htmlall'} {* escapes SEMUA entri html *}
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;

<a href="?title={$articleTitle|escape:'url'}">click here</a>
<a href="?title=%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27">click here</a>

{$articleTitle|escape:'quotes'}
\'Stiff Opposition Expected to Casketless Funeral Plan\'

<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
{$EmailAddress|escape:'mail'}    {* this converts to email to text *}
<a href="mailto:%62%6f%..snip..%65%74">&#x62;&#x6f;&#x62..snip..&#x65;&#x74;</a>

{'mail@example.com'|escape:'mail'}
smarty [AT] example [DOT] com

Teladan 5-11. Contoh lain

Fungsi PHP dapat dipakai sebagai pengubah, $security yang mengijinkan.

{* parameter "rewind" meregistrasi lokasi sekarang *}
<a href="{$SCRIPT_NAME}?page=foo&rewind={$smarty.server.REQUEST_URI|urlencode}">click here</a>

This snippet is useful for emails, but see also {mailto}

{* alamat email dipotong *}
<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>

Lihat juga escaping penguraian smarty, {mailto} dan halaman mengaburkan alamat email.

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors