Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplateProcessor.php print empty '' string if value is 0 #2572

Open
technilogics opened this issue Feb 16, 2024 · 3 comments
Open

TemplateProcessor.php print empty '' string if value is 0 #2572

technilogics opened this issue Feb 16, 2024 · 3 comments

Comments

@technilogics
Copy link

return $subject ? Text::toUTF8($subject) : '';

return $subject ? Text::toUTF8($subject) : '';

Cause issue if subject is 0, that actually i want to print,
but unfortunately when $subject=0 as string or int or char it results in false.

Please fix this issue

@haihuynh98
Copy link

I also encountered a similar problem, and I haven't been able to solve it yet.

@truestealth
Copy link

my way to solve it:
override PHPWord/src/PhpWord/TemplateProcessor.php in composer.json
and replace
return $subject ? Text::toUTF8($subject) : ''; >>> return (null !== $subject) ? Text::toUTF8($subject) : '';

@jeremygmajor
Copy link

Thanks @truestealth - works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants