Sample code for 30+ languages & platforms
PHP ActiveX

Convert HTML to Plain Text

Demonstrates how to convert HTML to plain text.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$h2t = new COM("Chilkat.HtmlToText");

$html = $h2t->readFileToString('c:/temp/test.html','utf-8');
if ($h2t->LastMethodSuccess == 0) {
    print $h2t->LastErrorText . "\n";
    exit;
}

$plainText = $h2t->toText($html);
if ($h2t->LastMethodSuccess == 0) {
    print $h2t->LastErrorText . "\n";
    exit;
}

print $plainText . "\n";

?>