Home  >  Article  >  Backend Development  >  How to clear script in php

How to clear script in php

藏色散人
藏色散人Original
2021-09-25 10:35:572406browse

How to clear script in php: 1. Create a PHP sample file; 2. Use the "function delScript($string){...}" method to remove the script in html.

How to clear script in php

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

php How to clear script?

php removes script from html

The code is as follows:

//去除 script 脚 本
function delScript($string){
   $pregfind = array("/<script.*>.*<//script>/siU",&#39;/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i&#39;);
   $pregreplace = array(&#39;&#39;,&#39;&#39;);
   $string = preg_replace($pregfind, $pregreplace, $string);
   return $string;
}

Mainly replace 3f1c4e4b6b16bbbd69b2ee476dc4f83a2cacc6d41bbb37262a98f745aa00fbf0 and the middle part with empty ones.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to clear script in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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