コード例 #1
0
ファイル: htmlTest.php プロジェクト: martinlindhe/core_dev
 public function testHtmlCharsDecode()
 {
     $this->assertEquals(htmlchars_decode('ja ha'), 'ja ha');
     // TODO hex encode nbsp character
     $this->assertEquals(htmlchars_decode('reg®me'), 'reg®me');
     $this->assertEquals(htmlchars_decode('''), "'");
 }
コード例 #2
0
ファイル: html.php プロジェクト: martinlindhe/core_dev
/** similar to strip_tags() but also removes all javascript / css inside <script> or <style> tags */
function strip_html($s)
{
    $search = array('@<!--' . '(?:' . '(?!-->)' . '.' . ')*' . '-->@si', '@<(script|style)[^>]*?>.*?</(script|style)>@si', '@<[\\/\\!]*?[^<>]*?>@si');
    $s = preg_replace($search, '', $s);
    $s = htmlchars_decode($s);
    return $s;
}
コード例 #3
0
ファイル: core.php プロジェクト: martinlindhe/core_dev
/**
 * reduce excessive whitespace to a single space
 */
function reduce_whitespace($s)
{
    $s = htmlchars_decode($s);
    $s = str_replace("\t", ' ', $s);
    //tabs -> spaces
    $s = str_replace("\n", ' ', $s);
    //linefeed -> spaces
    $s = str_replace("\r", ' ', $s);
    //linefeed -> spaces
    do {
        $tmp = $s;
        $s = str_replace('  ', ' ', $s);
    } while ($s != $tmp);
    return trim($s);
}