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. // $Id: html_entity_decode.php,v 1.11 2007/04/17 10:09:56 arpad Exp $
  3.  
  4.  
  5. if (!defined('ENT_NOQUOTES')) {
  6.     define('ENT_NOQUOTES'0);
  7. }
  8.  
  9. if (!defined('ENT_COMPAT')) {
  10.     define('ENT_COMPAT'2);
  11. }
  12.  
  13. if (!defined('ENT_QUOTES')) {
  14.     define('ENT_QUOTES'3);
  15. }
  16.  
  17.  
  18. /**
  19.  * Replace html_entity_decode()
  20.  *
  21.  * @category    PHP
  22.  * @package     PHP_Compat
  23.  * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
  24.  * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
  25.  * @link        http://php.net/function.html_entity_decode
  26.  * @author      David Irvine <dave@codexweb.co.za>
  27.  * @author      Aidan Lister <aidan@php.net>
  28.  * @version     $Revision: 1.11 $
  29.  * @since       PHP 4.3.0
  30.  * @internal    Setting the charset will not do anything
  31.  * @require     PHP 4.0.0 (user_error)
  32.  */
  33. function php_compat_html_entity_decode($string$quote_style = ENT_COMPAT$charset = null)
  34. {
  35.     if (!is_int($quote_style)) {
  36.         user_error('html_entity_decode() expects parameter 2 to be long, ' .
  37.             gettype($quote_style' given'E_USER_WARNING);
  38.         return;
  39.     }
  40.  
  41.     $trans_tbl get_html_translation_table(HTML_ENTITIES);
  42.     $trans_tbl array_flip($trans_tbl);
  43.  
  44.     // Add single quote to translation table;
  45.     if ($quote_style === ENT_QUOTES{
  46.         $trans_tbl['&#039;''\'';
  47.     }
  48.  
  49.     // Not translating double quotes
  50.     if ($quote_style === ENT_NOQUOTES{
  51.         // Remove double quote from translation table
  52.         unset($trans_tbl['&quot;']);
  53.     }
  54.  
  55.     return strtr($string$trans_tbl);
  56. }
  57.  
  58.  
  59. // Define
  60. if (!function_exists('html_entity_decode')) {
  61.     function html_entity_decode($string$quote_style = ENT_COMPAT$charset = null)
  62.     {
  63.         return php_compat_html_entity_decode($string$quote_style$charset);
  64.     }
  65. }

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