code属性值有html(同htmldecode)、quote和url(同urlencode),等,各自的功能如下:
html | 禁止htmlencode转换,默认是做转换,同:htmldecode |
quote | 删除双引号等,可以用在html属性值里 |
url | urlencode转换,传递URL的时候用到,同:urlencode |
nl2br | 回车符换成<br/>,在html页面中正常显示换行 |
ip | 把long格式的ip地址转换为 255.255.255.* 样式的地址 |
{$system.bottom code='html'} 或 {$title code='htmldecode'}
默认输出的所有标签是经过htmlencode转换了的,这样可以安全过滤掉用户提交的不安全的html代码,但一些特殊的文本段是不能转换的,比如页脚html代码、统计器代码或html编辑器中提交的内容,这个时候需要指定一下code值为html;必须要区分的是,这个和先前版本的属性的意义是正好相反。
{$title code='quote'}
当标签在html代码属性里需要用到的时候,指定一下quote,以免在数据中带有双引号等特殊符号的时候,发生错误。也可以用php的htmlspecialchars函数,但这个函数会把双引号换成",并不利于SEO优化。举例:
<img src="{$image}" alt="{$title code='quote'}"/>
{$_GET['q'] code='url'} 或 {$title code='urlencode'}
部分浏览器不支持直接传递中文,这个时候需要做urlencode转换,主要用处是传递到url参数时候用到。
<a href="{DIR}/?q={$_GET[q] code='url'}">搜索关键词</a>
例子:
code='quate'是删除标题中的双引号是删除标题中的双引号
{@res table='%s_content' field='title,url,date' where='status=1'} {#foreach($res as $rs)} <a href="{DIR}{$rs[url]}" title="{$rs[title]code='quote'}">{$rs[title] size='10'}</a> {#endforeach}code='quate'是删除标题中的双引号
转载请注明出处:唯众网络