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

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