smarty @Wiki

escape

最終更新:

匿名ユーザー

- view
だれでも歓迎! 編集

escape

パラメータの位置 型? 必須 有効な値 デフォルト 概要
1 string? No html,htmlall,url,quotes,hex,hexentity,javascript html 使用するエスケープフォーマット

htmlエスケープ・urlエスケープ・未エスケープの変数のシングルクォートのエスケープ・hexエスケープ・hexentityエスケープ・javascriptエスケープを行います。
デフォルトではhtmlエスケープが行われます。

例 5-10. escape

<?php
$smarty = new Smarty;
$smarty->assign('articleTitle', "'Stiff Opposition Expected to Casketless Funeral Plan'");
$smarty->display('index.tpl');
?>
index.tpl : 
{$articleTitle}
{$articleTitle|escape}
{$articleTitle|escape:"html"} {* & " ' < > をエスケープ *}
{$articleTitle|escape:"htmlall"} {* 全てのhtmlエンティティをエスケープ *}
{$articleTitle|escape:"url"}
{$articleTitle|escape:"quotes"}
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
出力 : 
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">bob@me.net</a>

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

記事メニュー
目安箱バナー