phpdocx使用wordfragment替换模板头变量不起作用

i am using phpdocx to genarate word document.

i have dynamically changed headers in words. so i want to replace header variable dnamically. phpdocx forum they say it can be done using WordFragment method but it not work.. http://www.zxcv.phpdocx.com/en/forum/default/topic/734

here is my code i put $TESTTT$ variable in header

//path to  the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';

$docx = new CreateDocxFromTemplate('Doc.docx');

//create the Word fragment that is going to replace the variable
$wf = new WordFragment($docx, 'document');
$text='try to add head';

$wf->addText($text);

$docx->replaceVariableByWordFragment(array('TESTTT' => $wf), array('type' => 'block'));


$docx->createDocx('tessst');

when creating from template you also need to add:

require_once '../../../classes/CreateDocxFromTemplate.inc';

Do you really need to use a Word fragment?

With PHPDocx you may easily replace text variables and placeholder images and that should be enough most of the time.

If it is not the case you may use the import headers and footers method or replace the whole thing with the add header method.

Currently phpdocx do not support changing variables by wordfragment either the header or footer.

This code is working with me

$docx = new CreateDocxFromTemplate('docTemplate/HeaderTest.docx');
$docx->setTemplateSymbol('#');
$variables = array('VAR_NAME' => "SOME TEXT");
$options = array('target' => 'header');
$docx->replaceVariableByText($variables, $options);