Hello,
That code is from the old phpdocx 3 that is not compatible with the current stable version of phpdocx. The phpdocx API is compatible with all versions since phpdocx 4; new versions add new features, methods, classes and options.
You can add HTML in headers and footers using WordFragments:
require_once 'classes/CreateDocx.php';
$docx = new CreateDocx();
$htmlHeader = '<p style="border: 2px solid black; color: red">A short text with a red border in headers.</p>';
$headerFragment = new WordFragment($docx, 'defaultHeader');
$headerFragment->embedHTML($htmlHeader);
$docx->addHeader(array('default' => $headerFragment));
$htmlFooter = '<p style="border: 2px solid black; color: red">A short text with a red border in footers.</p>';
$footerFragment = new WordFragment($docx, 'defaultFooter');
$footerFragment->embedHTML($htmlFooter);
$docx->addFooter(array('default' => $footerFragment));
$htmlBody = '<p style="font-weight: bold;">Body content.</p>';
$docx->embedHTML($htmlBody);
$docx->createDocx('output');
On the practical guide you can find more information about WordFragments: https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml
You can also generate headers and footers from HTML tags using HTML Extended available in Premium licenses:
https://www.phpdocx.com/htmlapi-documentation/html-extended/insert-header-Word-document-with-HTML
https://www.phpdocx.com/htmlapi-documentation/html-extended/insert-footer-Word-document-with-HTML
Regards.