root/trunk/framework/Web/THttpUtility.php

Revision 2482, 1.2 kB (checked in by knut, 4 months ago)

updated copyright

  • Property svn:keywords set to Id
Line 
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$
10 * @package System.Web
11 */
12
13/**
14 * THttpUtility class
15 *
16 * @author Qiang Xue <qiang.xue@gmail.com>
17 * @version $Id$
18 * @package System.Web
19 * @since 3.0
20 */
21class 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
51?>
Note: See TracBrowser for help on using the browser.