Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * THttpUtility class file
4
 *
5
 * @author Qiang Xue <qiang.xue@gmail.com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: THttpUtility.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web
11
 */
12
 
13
/**
14
 * THttpUtility class
15
 *
16
 * @author Qiang Xue <qiang.xue@gmail.com>
17
 * @version $Id: THttpUtility.php 2541 2008-10-21 15:05:13Z qiang.xue $
18
 * @package System.Web
19
 * @since 3.0
20
 */
21
class THttpUtility
22
{
23
	private static $_encodeTable=array('<'=>'&lt;','>'=>'&gt;','"'=>'&quot;');
24
	private static $_decodeTable=array('&lt;'=>'<','&gt;'=>'>','&quot;'=>'"');
25
 
26
	/**
27
	 * HTML-encodes a string.
28
	 * This method translates the following characters to their corresponding
29
	 * HTML entities: <, >, "
30
	 * Note, unlike {@link htmlspeicalchars}, & is not translated.
31
	 * @param string string to be encoded
32
	 * @return string encoded string
33
	 */
34
	public static function htmlEncode($s)
35
	{
36
		return strtr($s,self::$_encodeTable);
37
	}
38
 
39
	/**
40
	 * HTML-decodes a string.
41
	 * It is the inverse of {@link htmlEncode}.
42
	 * @param string string to be decoded
43
	 * @return string decoded string
44
	 */
45
	public static function htmlDecode($s)
46
	{
47
		return strtr($s,self::$_decodeTable);
48
	}
49
}
50