Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use php to clear script

Shulou Source: shulou.com Published: 2022-06-03 10:05:31 11月15日 Update

How to use php to clear script, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this to learn, I hope you can gain something.

php Clear script method: 1, Create a PHP sample file;2, By "function delScript($string){...} "Method removes script from html.

Operating environment: Windows 7, PHP 7.1, DELL G3

How does PHP clear scripts?

PHP removes script from html

The code is as follows:

//remove script function delScript($string){ $pregfind = array("/.*/ siU",'/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i'); $pregreplace = array('',''); $string = preg_replace($pregfind, $pregreplace, $string); return $string;}

The main thing is to replace the middle part with empty.

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Tags: Methods help clarity code content this documents articles novices more environment computers knowledge examples systems industry information information channels problems requirements Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft Shulou Information vpn Huawei