PHP Classes
elePHPant
Icontem

File: htmlstriptestinBrowser.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Mo´se  >  PHP Strip HTML Tags  >  htmlstriptestinBrowser.php  >  Download  
File: htmlstriptestinBrowser.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Strip HTML Tags
Process HTML to strip tags, attributes or PHP code
Author: By
Last change: Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
Date: 3 months ago
Size: 1,416 bytes
 

 

Contents

Class file image Download
<?php


$DIR
=__DIR__.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR;
foreach (array(
'DOMNodeRecursiveIterator', 'beforeStrip', 'prepareStrip', 'htmlStripHelper', 'htmlStrip') as $file) {
    require_once(
$DIR.$file.'.php');
}

use
EZAMA\htmlStrip;

$x='<script type="text/javascript" async="" src="./Transitioning%20from%20Data%20Developer%20to%20Data%20Scientist%20-%20Statistics%20for%20Data%20Science_files/f.txt"></script>';
$data='aaaaa<?php echo here ; ?><!doctype><html><head>'.$x.'</head><!-- a comment --> <body> <?php echo here ; ?><br><br> <h2 onmousedown="alert(\'keke\');">u</h2><p></p><h2>a</h2></body></html>b2b2 ';

$hstrip=new htmlStrip($data, 'replace', array('<h2>', false));
var_dump($hstrip->go()===strip_tags($data, '<h2>')); //true


$hstrip=new htmlStrip($data);
var_dump($hstrip->go()===strip_tags($data)); //true

$hstrip=new htmlStrip($data, 'replace', array('', true), array('src', true));
var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), 'src')); //false


$hstrip=new htmlStrip($data, 'replace', array('', true), array('src', false));
var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), ' type')); //false
var_dump((bool)stripos($hstrip->go(htmlStrip::ATTRIBUTES), 'src')); //true;

$hstrip=new htmlStrip($data, 'replace', array('<doctypetag>', true));
$hstrip1=new htmlStrip($data, 'replace', array('<!doctype>', true));
var_dump($hstrip->go()===$hstrip1->go());