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

Class: HTML_Entities

Source Location: /HTML_Entities-0.2.2/Entities.php

Class Overview


Convert utf8 (or other text encoding) to HTML entities, and vice-versa


Author(s):

Version:

  • Release: 0.2.2

Methods


Inherited Variables

Inherited Methods


Class Details

[line 78]
Convert utf8 (or other text encoding) to HTML entities, and vice-versa

All functions are static. Functions use utf8 encoding. It uses utf8_encode and utf8_decode functions to deal with latin1 (iso-8859-1) and iconv (if available) to deal with other charsets.

The default behavior is to encode utf8 strings using named entities compatible with HTML 4.0, and to decode all entities.

Examples:

$myencodedtext = HTML_Entities::encode($mytext); $mytextagain = HTML_Entities::decode($myencodedtext);

To encode using numerical entities: $myencodedtext = HTML_Entities::encode($mytext, HTML_Entities::CODES)

To encode HTML, without touching HTML tags: $myencodedtext = HTML_Entities::encode($mytext, HTML_Entities::NAMES, HTML_Entities::HTML40 | HTML_Entities::IGNORE_SPECIAL_CHARS)

To decode to latin1: HTML_Entities::decode($mytext, HTML_Entities::ALL, 'latin1');

The list of entities was taken here: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references



[ Top ]


Method Detail

decode   [line 287]

string decode( string $text, [int $options = self::ALL], [string $charset = 'utf-8'])

Decode $text
  • Return: The encoded text
  • Access: public

Parameters:

string   $text   —  The text to decode
int   $options   —  Compatibility mode (HTML 2.0, 3.2, 4.0, XHTML 1.0)
string   $charset   —  Charset of the output

[ Top ]

encode   [line 150]

string encode( string $text, [int $what = self::NAMES], [int $compat = self::HTML40], [string $charset = 'utf-8'])

Encode $text with HTML entities.
  • Return: The encoded text
  • Access: public

Parameters:

string   $text   —  The text to encode
int   $what   —  What kind of encoding to use (names and/or codes)
int   $compat   —  Compatibility mode (HTML 2.0, 3.2, 4.0, XHTML 1.0)
string   $charset   —  Charset of the input string

[ Top ]

getTranslationTable   [line 396]

array getTranslationTable( [int $options = self::ALL])

Get the translation table.
  • Return: The array of named entities, associated with utf8 chars.
  • Access: public

Parameters:

int   $options   —  Compatibility mode.

[ Top ]


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