smarty_strip使得脚本乱码以防止他人盗用模版代码

本文介绍了一个使用PHP Smarty模板引擎中的strip功能来使HTML代码紧凑,从而达到保护模板代码免遭盗用的方法。通过strip功能去除HTML标签间的空格,使得代码变得难以阅读,增加了模板的保护力度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

strip能去除html脚本中标签间空格,使得脚本乱码以防止他人盗用模版代码

1、strip.php代码如下:
<?php
/*
*strip能去除html脚本中标签之间的空格,利用此功能可以使得脚本乱码以防止他人盗用模版代码
*/
include("smarty_inc.php");
$mess="this is a example for use strip!";
$mess2="this is a example for don't uer strip!";
$smarty->assign("mess",$mess);
$smarty->assign("mess2",$mess2);
$smarty->display("strip.htm");
?>
2、strip.htm代码如下:
{strip} <!-- 使用strip实现代码乱码-->
<table border=1>
<tr>
<td>
{$mess}
</td>
</tr>
</table><!-- 这里的代码是不规整的! -->

{/strip}
<table border=1>
<tr>
<td>
{$mess2}
</td>
</tr>
</table>

运行后脚本代码如下:
<!-- 使用strip实现代码乱码--><table border=1><tr><td>this is a example for use strip!</td></tr></table><!-- 这里的代码是不规整的! -->
<table border=1>
<tr>
<td>
this is a example for don't uer strip!
</td>
</tr>
</table>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值