Test environment: Windows Server2003 + PHP5.3.5 _ TS + Apache2.2.19
Create 1.php and put it in the localhot root directory. The file content is as follows:
<? Php
Set_error_handler (function (){
Echo 'error occurred ';
});
Set_exception_handler (function (){
Echo 'error occurred ';
});
Error_reporting (E_ALL &~ E_NOTICE );
// A piece of html text
$ Html = '<div class = "play_video"> <div id = "div_D65EEBE0-2955-A608-27A6-CB5713579FC2"> </div> <script type = "text/javascript"> swfobject. embedSWF ("/flash/player.swf", "div_D65EEBE0-2955-A608-27A6-CB5713579FC2", "500", "300", "9.0.0", "/flash/expressInstall.swf", {file: "/videos/2011/12/26/15/channels" },{ wmode: "opaque", allowfullscreen: "true", allowscriptaccess: "always" },{ id: "player_D65EEBE0-2955-A608-27A6-CB5713579FC2 ", wmode: "opaque"}); </script> ';
// A regular expression for removing script Blocks
$ Reg = '# <script [^>] *> (((?! (? <! [\ '""]) <\/? Script> (?! [\ '""]) [\ S \ S]) *) </script> # I ';
// Replace the regular expression, remove the script, and kill the current http connection when executing this sentence, the status code of this connection was found to be 0 using Fiddler monitoring (no status code found online. 0 indicates what it means)
$ Html = preg_replace ($ reg, '', $ html );
Echo $ html;
?>
Open http: // localhost/1.php in Chrome, and the following error occurs: 324 (net: ERR_EMPTY_RESPONSE): the server is disconnected and no data is sent.