25 lines
504 B
PHP
25 lines
504 B
PHP
|
<?php
|
||
|
|
||
|
class HTMLTools {
|
||
|
|
||
|
private static $invisibleSpace = '<span class="invisiblespace"> </span>';
|
||
|
|
||
|
public static function makeSafe ($string) {
|
||
|
|
||
|
return htmlentities($string);
|
||
|
|
||
|
}
|
||
|
|
||
|
public static function makeSafeAndWrapBetter ($string) {
|
||
|
|
||
|
return preg_replace(
|
||
|
array('~/|-|\.~'),
|
||
|
array(static::$invisibleSpace.'$0'.static::$invisibleSpace), // Put an invisible space before and after each slash, hyphen and period
|
||
|
static::makeSafe($string)
|
||
|
);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|