Home > Backend Development > PHP Problem > How to clear script in php

How to clear script in php

藏色散人
Release: 2023-03-12 22:26:01
Original
2617 people have browsed it

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;
}
Copy after login

Mainly replace <script></script> 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!

Related labels:
source:php.cn
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