PHP 7.4 修剪字符串变量之间的空格 [英] PHP 7.4 trimming whitespace between string variables

查看:34
本文介绍了PHP 7.4 修剪字符串变量之间的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,当我将多个变量输出到一个类属性中时,它们都被压缩成一个单词,而不是像最初编写的那样作为单独的单词保存,如

<div class="className {{ variable1 }} {{ variable2 }}"><div>

在运行时呈现为:

知道什么会导致这种情况以及如何避免吗?

解决方案

在 PHP 7.4 上遇到了同样的问题.在 GitHub 上找到此 fix.

因此,如果您使用的是 Twig 1,请至少将其升级到 v1.43.0.

如果您使用的是 Twig 2,请至少将其升级到 v2.10.0.(我的情况 - 我在项目中有 v2.7.4).

I'm running into an issue where when I have multiple variables being output into a class attribute, they all get compressed into a single word rather than kept as separate words as originally authored, as in

<div class="className {{ variable1 }} {{ variable2 }}"><div>

At runtime this is being rendered as:

<div class="className variable1variable2"><div>

Any idea what would cause this and how to avoid it?

解决方案

Faced the same issue on PHP 7.4. Found this fix on GitHub.

So if you're using Twig 1, upgrade it at least to v1.43.0.

If you're using Twig 2, upgrade it at least to v2.10.0. (my case - I had v2.7.4 in the project).

这篇关于PHP 7.4 修剪字符串变量之间的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆