Forum


Replies: 1   Views: 3798
Variable $date$ problem
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by blocked-falcana-blocked  · 17-06-2014 - 14:31

I'm using a variable $date$ in my docx. When using $docx->replaceVariableByText(array('date'=>'01.01.2014'), $options); in my script, the content is not available in the document. The $date$ variable is replaced, but the value doesn't appear. The result is the same as if the value was empty. If I rename the variable e.g. to $dat$, everything works fine. So the var name "date" seems to make the problem.

Posted by admin  · 23-06-2014 - 14:55

Hello, We have done some tests with this code: ----------------------------- require_once '../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('TemplateSimpleText.docx'); $first = 'PHPDocX'; $multiline = 'This is the first line.\nThis is the second line of text.'; $variables = array('date' => '01.01.2014'); $options = array('parseLineBreaks' =>true); $docx->replaceVariableByText($variables, $options); $docx->createDocx('example_replaceVariableByText_1'); ----------------------------- And the document is generated without issues. So there must be an error in your template or code; we recommend you to check both. Regards.