gpt4 book ai didi

php - 在表格中,
标签显示在屏幕上而不是换行

转载 作者:太空宇宙 更新时间:2023-11-04 14:29:28 30 4
gpt4 key购买 nike

我有一个 <table>和里面<td>我在其中显示从后端检索到的数据的标签。在将我的数据保存到数据库之前,我用它来转换 \n\r进入<br />标签:

$data = nl2br($request->data);
$data = str_replace(array("\r\n", "\n\r", "\r", "\n"), "", $data);

为了检索数据,我尝试直接回显值 - ({{ }} 是 Laravel 的回显)

<tr> 
<td>{{ $item->data }}</td>
</tr>

但是,这是显示 <br />页面上的标记,而不是将它们变成新的换行符。


然后我尝试使用这种方法,我相信它会起作用,但是,这也会显示 &#13;在文本上而不是将其转换为新行。

<tr> 
<td>@if ($item){{ str_replace('<br />', '&#13;', $item->data) }}@endif</td>
</tr>

还尝试将 br 标签替换为 \n使用 '\n''\\n'里面str_replace()但没有运气

我怎样才能转 <br />像往常一样在表内标记新行?

最佳答案

这与表格无关。

参见 the documentation :

Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks.

By default, Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax:

Hello, {!! $name !!}.

Be very careful when echoing content that is supplied by users of your application. Always use the escaped, double curly brace syntax to prevent XSS attacks when displaying user supplied data.

关于php - 在表格中,<br/> 标签显示在屏幕上而不是换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40666372/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com