Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从html中删除activex_Php_Html_String_Parsing_Activex - Fatal编程技术网

Php 从html中删除activex

Php 从html中删除activex,php,html,string,parsing,activex,Php,Html,String,Parsing,Activex,我有一个php脚本,我正试图编写。假设脚本以字符串的形式打开一个html文件,并为标记解析字符串。我想删除对象标记之间的所有内容以及它们自身的标记。解析完成后,我希望它保存文件。这是我到目前为止的代码 <?php $handle = file_get_contents("index.htm", "r"); #$str = preg_replace("/<object[0-9 a-z_?*&=\":\-\/\.#\,<>\\n\\r\\t]+<\/object

我有一个php脚本,我正试图编写。假设脚本以字符串的形式打开一个html文件,并为标记解析字符串。我想删除对象标记之间的所有内容以及它们自身的标记。解析完成后,我希望它保存文件。这是我到目前为止的代码

<?php
$handle = file_get_contents("index.htm", "r");
#$str = preg_replace("/<object[0-9 a-z_?*&=\":\-\/\.#\,<>\\n\\r\\t]+<\/object>/smi", "", >             $str);
strip_tags("<object>", "</object>")
print "$handle"
?>

下面是代码

             include './simple_html_dom.php';
            // replace this url with your file url
            $file = "http://localhost:8012/PhpProject1/file.html";
            $html = file_get_html($file);
            foreach($html->find('object') as $element) 
            {
                            $element->outertext = '';
            }
            // this is your html without Object tags 
            echo $html;
从下载库


希望它能起作用

您可以看看HTMLPurifier。不要使用正则表达式。你只会把你的文件弄得乱七八糟。使用这两种方法删除标记及其内容非常简单,我将对这两种方法进行研究。谢谢大家。效果很好,但是我如何用新的输出覆盖现有的文件呢?只需简单的php文件@Dk6861636b