source: branches/version-2_5-dev/data/module/Compat/Compat/Function/htmlspecialchars_decode.php @ 20119

Revision 20119, 2.7 KB checked in by nanasess, 13 years ago (diff)

module 以下は svn:keywords を除外

  • Property svn:eol-style set to LF
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?PHP
2// +----------------------------------------------------------------------+
3// | PHP Version 4                                                        |
4// +----------------------------------------------------------------------+
5// | Copyright (c) 1997-2004 The PHP Group                                |
6// +----------------------------------------------------------------------+
7// | This source file is subject to version 3.0 of the PHP license,       |
8// | that is bundled with this package in the file LICENSE, and is        |
9// | available at through the world-wide-web at                           |
10// | http://www.php.net/license/3_0.txt.                                  |
11// | If you did not receive a copy of the PHP license and are unable to   |
12// | obtain it through the world-wide-web, please send a note to          |
13// | license@php.net so we can mail you a copy immediately.               |
14// +----------------------------------------------------------------------+
15// | Authors: Stephan Schmidt <schst@php.net>                             |
16// |          Aidan Lister <aidan@php.net>                                |
17// +----------------------------------------------------------------------+
18//
19// $Id: htmlspecialchars_decode.php,v 1.3 2005/06/18 14:02:09 aidan Exp $
20
21
22/**
23 * Replace function htmlspecialchars_decode()
24 *
25 * @category    PHP
26 * @package     PHP_Compat
27 * @link        http://php.net/function.htmlspecialchars_decode
28 * @author      Aidan Lister <aidan@php.net>
29 * @version     $Revision: 1.3 $
30 * @since       PHP 5.1.0
31 * @require     PHP 4.0.0 (user_error)
32 */
33if (!function_exists('htmlspecialchars_decode')) {
34    function htmlspecialchars_decode($string, $quote_style = null)
35    {
36        // Sanity check
37        if (!is_scalar($string)) {
38            user_error('htmlspecialchars_decode() expects parameter 1 to be string, ' .
39                gettype($string) . ' given', E_USER_WARNING);
40            return;
41        }
42
43        if (!is_int($quote_style) && $quote_style !== null) {
44            user_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' .
45                gettype($quote_style) . ' given', E_USER_WARNING);
46            return;
47        }
48
49        // Init
50        $from   = array('&amp;', '&lt;', '&gt;');
51        $to     = array('&', '<', '>');
52       
53        // The function does not behave as documented
54        // This matches the actual behaviour of the function
55        if ($quote_style & ENT_COMPAT || $quote_style & ENT_QUOTES) {
56            $from[] = '&quot;';
57            $to[]   = '"';
58           
59            $from[] = '&#039;';
60            $to[]   = "'";
61        }
62
63        return str_replace($from, $to, $string);
64    }
65}
66
67?>
Note: See TracBrowser for help on using the repository browser.