/
html.php
90 lines (80 loc) · 1.79 KB
/
html.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @author Marwan Al-Soltany <MarwanAlsoltany@gmail.com>
* @copyright Marwan Al-Soltany 2021
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
if (!function_exists('he')) {
/**
* Encodes the passed text with `htmlentities()`.
*
* @param string $text
*
* @return string
*/
function he($text) {
return htmlentities((string)$text, ENT_QUOTES, 'UTF-8');
}
}
if (!function_exists('hd')) {
/**
* Decodes the passed text with `html_entity_decode()`.
*
* @param string $text
*
* @return string
*/
function hd($text) {
return html_entity_decode((string)$text, ENT_QUOTES, 'UTF-8');
}
}
if (!function_exists('hse')) {
/**
* Encodes the passed text with `htmlspecialchars()`.
*
* @param string $text
*
* @return string
*/
function hse($text) {
return htmlspecialchars((string)$text, ENT_QUOTES, 'UTF-8');
}
}
if (!function_exists('hsd')) {
/**
* Decodes the passed text with `htmlspecialchars_decode()`.
*
* @param string $text
*
* @return string
*/
function hsd($text) {
return htmlspecialchars_decode((string)$text, ENT_QUOTES, 'UTF-8');
}
}
if (!function_exists('st')) {
/**
* Strips the passed text with `strip_tags()`.
*
* @param string $text
*
* @return string
*/
function st($text) {
return strip_tags((string)$text);
}
}
if (!function_exists('nb')) {
/**
* Turns `\n` to `<br>` in the passed text with `nl2br()`.
*
* @param string $text
*
* @return string
*/
function nb($text) {
return nl2br((string)$text);
}
}