# 帝国CMS如何使静态内容页面生成为压缩代码

*Published:* 2023-12-18
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年12月18日，已超过 180天没有更新



解决方法：

1、打开文件e/class/functions.php

2、找到以下函数

```
function GetHtml($classid,$id,$add,$ecms=0,$doall=0)
```

3、在//写文件之前添加代码

```
preg_match_all('/(.*?)/s',$string,$r);
foreach ($r[0] as $key => $value) {
    $string=str_replace($value, "[#]".$key."[#]", $string);
}
$string=preg_replace('[rn]', '',$string);
$string=preg_replace('/>s+(.*?)<', $string);
foreach ($r[0] as $key => $value) {
    $string=str_replace("[#]".$key."[#]",$value, $string);
}
//写文件
WriteFiletext($file,$addlevel.$string);
```

修改后再生成的[内容页](https://www.xarjtc.com/tag/%e5%86%85%e5%ae%b9%e9%a1%b5 "查看内容页此标签更多文章")就只有一行源码。