Home > CMS Tutorial > Empire CMS > Share custom functions to solve the problem of HTML when intercepting characters in the introduction of Empire CMS

Share custom functions to solve the problem of HTML when intercepting characters in the introduction of Empire CMS

silencement
Release: 2019-12-02 15:51:28
forward
1928 people have browsed it

Share custom functions to solve the problem of HTML when intercepting characters in the introduction of Empire CMS

My solution is as follows. I wrote a function and added it. Let’s see if it works. If there are any problems, I think it’s okay.

First of all, e/ Add a custom function such as NoHTML() to the class/connect.php file. This can be set casually if you like.

The code is as follows:

//去除HTML标记
function NoHTML($string){
$string = preg_replace("&#39;<script[^>]*?>.*?</script>&#39;si", "", $string);//去掉javascript
$string = preg_replace("&#39;<[\/\!]*?[^<>]*?>&#39;si", "", $string); //去掉HTML标记
$string = preg_replace("&#39;([\r\n])[\s]+&#39;", "", $string); //去掉空白字符
$string = preg_replace("&#39;&(quot|#34);&#39;i", "", $string); //替换HTML实体
$string = preg_replace("&#39;&(amp|#38);&#39;i", "", $string);
$string = preg_replace("&#39;&(lt|#60);&#39;i", "", $string);
$string = preg_replace("&#39;&(gt|#62);&#39;i", "", $string);
$string = preg_replace("&#39;&(nbsp|#160);&#39;i", "", $string);
return $string;
}
Copy after login

Recommended to study "Empirecms Tutorial

Then go to the list content template and modify the code

The code is as follows:

$r[smalltext]=esub(NoHTML($r[smalltext]),200,&#39;......&#39;);$listtemp=&#39;<li><strong><a href="[!--titleurl--]">
[!--title--]</a></strong><p>[!--smalltext--]</p></li>&#39;;
Copy after login

The problem is solved, it is very simple.
Because it is Chinese For English websites, the website name needs to use a title, so it is very convenient to modify it like this

The above is the detailed content of Share custom functions to solve the problem of HTML when intercepting characters in the introduction of Empire CMS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:www.word666.com/cms
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template