aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr/sys/Esc.php
diff options
context:
space:
mode:
Diffstat (limited to 'ratatoeskr/sys/Esc.php')
-rw-r--r--ratatoeskr/sys/Esc.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/ratatoeskr/sys/Esc.php b/ratatoeskr/sys/Esc.php
new file mode 100644
index 0000000..eaefc10
--- /dev/null
+++ b/ratatoeskr/sys/Esc.php
@@ -0,0 +1,22 @@
+<?php
+
+
+namespace r7r\cms\sys;
+
+class Esc
+{
+ public const HTML = 1;
+ public const NL2BR = 2;
+ public const HTML_WITH_BR = self::HTML | self::NL2BR;
+
+ public static function esc(string $s, int $flags = self::HTML): string
+ {
+ if ($flags & self::HTML) {
+ $s = htmlspecialchars($s, ENT_QUOTES, "UTF-8");
+ }
+ if ($flags & self::NL2BR) {
+ $s = nl2br($s);
+ }
+ return $s;
+ }
+}