aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Text.php
blob: 4a962670a9fce8b917340d5a4798da6435009297 (plain) (blame)
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
<?php

namespace Zotlabs\Lib;

class Text {

	/**
	 * use this on "body" or "content" input where angle chars shouldn't be removed,
	 * and allow them to be safely displayed.
	 *
	 * @param string $string
	 *
	 * @return string
	 */

	public static function escape_tags(string $string): string {
		if (!$string) {
			return EMPTY_STR;
		}

		return htmlspecialchars($string, ENT_COMPAT, 'UTF-8', false);
	}

	public static function rawurlencode_parts(string $string): string {
		if (!$string) {
			return EMPTY_STR;
		}

		return implode('/', array_map('rawurlencode', explode('/', $string)));
	}


}