状态 草稿
Todo Proof read
官方最后更新时间 2008/05/01 20:31

安全性辅助函数

安全性辅助函数用于确认用户输入的安全性。

方法

xss_clean()

'xss_clean' 方法和输入类里的 xss_clean 是一样的。

  • [string] 被清除的字符串

strip_image_tags()

'strip_image_tags()' 删除内容中的图片标签(即img标签),并返回删除图片标签(img标签)以后的内容。

  • [string] 需要处理的字符串
$string = '<b>Check this image:</b> <img src="http://www.example.com/example.jpg" />';
print Kohana::debug(security::strip_image_tags($string));

返回结果:

<b>Check this image:</b> http://www.example.com/example.jpg

encode_php_tags()

'encode_php_tags' 这个函数可以把 PHP 脚本标签转成对应的 HTML 实体数据。

  • [string] 需要转换的字符串
$string = '<?php echo "<b>Hello World!</b>" ?>';
print Kohana::debug(security::encode_php_tags($string));

返回结果:

&lt;?php echo "<b>Hello World!</b>" ?&gt;
helpers/security.txt · 最后更改: 2008/11/05 17:26 由 icyleaf