Sample code for 30+ languages & platforms
PHP Requires Chilkat v11.1.0+

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\StringBuilder;

$sb = new StringBuilder();

$s = '< é ü ç Ω Hello & World ✓ >';
$sb->Append($s);

$sb->Encode('html', 'utf-8');
echo $sb->GetAsString(), "\n";

// Output:
// < &eacute; &uuml; &ccedil; &ohm; Hello & World &check; >

// To decode:
$sb->Decode('html', 'utf-8');
echo $sb->GetAsString(), "\n";

// Output:
// < é ü ç Ω Hello & World ✓ >