Download .zip |
Info | Documentation | View files (10) | Download .zip | Reputation | Support forum (2) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-02-01 (16 hours ago) | Not enough user ratings | Total: 235 This week: 22 | All time: 7,575 This week: 57 |
Version | License | PHP version | Categories | |||
htmlentities 4.5 | MIT/X Consortium ... | 5.4.0 | HTML, PHP 5, Text processing |
Description | Author | |||
This class can encode and decode a longer list of HTML entities. Innovation Award
|
The ability to encode and decode a certain set of characters called 'Html Entities' has existed since PHP4. Amongst the vast number of functions built into PHP, there are 4 nearly identical functions that are used to encode and decode html entities; despite their similarities, however, 2 of them do provide additional capabilities not available to the others.
| Encoding Functions | Decoding Functions | |--------------|--------------| | htmlentities¹ | html_entity_decode¹ | | htmlspecialchars² | htmlspecialchars_decode² |
__¹__ htmlentities and html_entity_decode can only encode and decode characters within PHP's HTML translations table.
__²__ htmlspecialchars and htmlspecialchars_decode can only encode and decode special characters³.
__³__ special characters are not interpreted as HTML tags and 8-bit characters are encoded as ASCII characters only.
What sets this class apart from the rest is that this class, in addition to being able to encode and decode all of the same characters/entities that can be encoded and decoded by PHP's htmlentities() and html_entity_decode() functions, it can also encode and decode a very large number of characters/entities which PHP's built-in htmlentities encoding and decoding functions won't encode/decode, due to their lack of special meaning in HTML, like:
- punctuation characters; - ASCII characters; - Greek characters; - Latin characters; - Russian characters; - Arithmetic characters; - and tons more...
composer require gavinggordon/htmlentities
include_once( __DIR__ . '/vendor/autoload.php' );
$htmlentities = new \GGG\HtmlEntities();
$to_encode = 'Test-,;:';
// Set a variable containing a string of the encoded characters you wish to be encoded;
$encoded = $htmlentities->encode( $to_encode );
// Get the encoded result by using the encode method on the returned instance of HtmlEntities;
echo $encoded;
// Display the encoded result, which is of type String;
// Test‐,;:
$to_decode = 'Test˜*(#';
// Set a variable containing a string of the encoded characters you wish to be decoded;
$decoded = $htmlentities->decode( $to_decode );
// Get the decoded result by using the decode method on the returned instance of HtmlEntities;
echo $decoded;
// Display the decoded result, which is of type String;
// Test~*(#
Check out our CodeClimate stats by clicking here.
This class has been awarded a PHP Innovation Award, provided by PHPClasses.org. My other PHP classes are accessible online via my GitHub profile or PHPClasses.org profile.
Files |
File | Role | Description | ||
---|---|---|---|---|
build (1 directory) | ||||
.codeclimate.yml | Data | Auxiliary data | ||
.scrutinizer.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Composer package file | ||
ggg_htmlentities_tests | Screen | Screenshot of tests | ||
LICENSE.txt | Doc. | Documentation | ||
license.txt | Doc. | Documentation | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Information and Examples |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
90% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.