PHP_Compat
[ class tree: PHP_Compat ] [ index: PHP_Compat ] [ all elements ]

Source for file html_entity_decode.php

Documentation is available at html_entity_decode.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: David Irvine <dave@codexweb.co.za>                          |
  17. // |          Aidan Lister <aidan@php.net>                                |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: html_entity_decode.php,v 1.3 2004/06/20 18:55:52 aidan Exp $
  21. //
  22.  
  23.  
  24. if (!defined('ENT_NOQUOTES')) {
  25.     define('ENT_NOQUOTES'0);
  26. }
  27.  
  28. if (!defined('ENT_COMPAT')) {
  29.     define('ENT_COMPAT'2);
  30. }
  31.  
  32. if (!defined('ENT_QUOTES')) {
  33.     define('ENT_QUOTES'3);
  34. }
  35.  
  36.  
  37. /**
  38.  * Replace html_entity_decode()
  39.  *
  40.  * @category    PHP
  41.  * @package     PHP_Compat
  42.  * @link        http://php.net/function.html_entity_decode
  43.  * @author      David Irvine <dave@codexweb.co.za>
  44.  * @author      Aidan Lister <aidan@php.net>
  45.  * @version     $Revision: 1.3 $
  46.  * @since       PHP 4.3.0
  47.  * @internal    Setting the charset will not do anything
  48.  * @require     PHP 4.0.1 (trigger_error)
  49.  */
  50. if (!function_exists('html_entity_decode'))
  51. {
  52.     function html_entity_decode ($string$quote_style = ENT_COMPAT$charset = null)
  53.     {
  54.         if (!is_int($quote_style)) {
  55.             trigger_error('html_entity_decode() expects parameter 2 to be long, ' gettype($quote_style' given'E_USER_WARNING);
  56.             return null;
  57.         }
  58.         
  59.         $trans_tbl get_html_translation_table(HTML_ENTITIES);
  60.         $trans_tbl array_flip($trans_tbl);
  61.  
  62.         // Add single quote to translation table;
  63.         $trans_tbl['&#039;''\'';
  64.  
  65.         // Not translating double quotes
  66.         if ($quote_style ENT_NOQUOTES
  67.             // Remove double quote from translation table
  68.             unset($trans_tbl['&quot;']);
  69.         }
  70.  
  71.         return strtr($string$trans_tbl);
  72.     }
  73. }
  74. ?>

Documentation generated on Mon, 11 Mar 2019 13:52:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.