diff options
Diffstat (limited to 'src/Esc.php')
-rw-r--r-- | src/Esc.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Esc.php b/src/Esc.php new file mode 100644 index 0000000..5c290b6 --- /dev/null +++ b/src/Esc.php @@ -0,0 +1,21 @@ +<?php + + +namespace Micropoly; + + +class Esc +{ + public const HTML = 1; + public const NL2BR = 2; + public const HTML_WITH_BR = self::HTML | self::NL2BR; + + public static function e(string $s, int $flags = self::HTML): string + { + if ($flags & self::HTML) + $s = htmlspecialchars($s); + if ($flags & self::NL2BR) + $s = nl2br($s); + return $s; + } +}
\ No newline at end of file |