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.
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",'/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i'); $pregreplace = array('',''); $string = preg_replace($pregfind, $pregreplace, $string); return $string; }
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!