I was try with sample Template.php in download packet with value contain '&' and get error "Illegal name character."
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('Template.docx');
$document->setValue('Value1', 'Sun abc/123 & 4');
$document->setValue('Value2', 'Mercury & Test');
$document->setValue('Value3', 'Venus');
$document->setValue('Value4', 'Earth');
$document->setValue('Value5', 'Mars');
$document->setValue('Value6', 'Jupiter');
$document->setValue('Value7', 'Saturn');
$document->setValue('Value8', 'Uranus');
$document->setValue('Value9', 'Neptun');
$document->setValue('Value10', 'Pluto');
$document->setValue('weekday', date('l'));
$document->setValue('time', date('H:i'));
$document->save('Solarsystem.docx');
Maybe a bug here. Any help would be great
Comments: I believe this solution is correct to your issue. Please update when possible. Handling special characters like that is something you should get accustomed to, especially if sourcing data/documents from multiple platforms (Mac,Linux,Windows).
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('Template.docx');
$document->setValue('Value1', 'Sun abc/123 & 4');
$document->setValue('Value2', 'Mercury & Test');
$document->setValue('Value3', 'Venus');
$document->setValue('Value4', 'Earth');
$document->setValue('Value5', 'Mars');
$document->setValue('Value6', 'Jupiter');
$document->setValue('Value7', 'Saturn');
$document->setValue('Value8', 'Uranus');
$document->setValue('Value9', 'Neptun');
$document->setValue('Value10', 'Pluto');
$document->setValue('weekday', date('l'));
$document->setValue('time', date('H:i'));
$document->save('Solarsystem.docx');
Maybe a bug here. Any help would be great
Comments: I believe this solution is correct to your issue. Please update when possible. Handling special characters like that is something you should get accustomed to, especially if sourcing data/documents from multiple platforms (Mac,Linux,Windows).