Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个排序为 latin1_swedish_ci 的 MySQL 数据库。
该字段在 DB 中如下所示:
输出时我这样做:
echo str_replace("<br />", "\n", trim($post->getContent()));
$post->getContent() 只是从数据库中获取字段,而不是从数据库中手动进行回显。
问题是当我更新字段时,我得到双换行符(只是更新而不添加换行符)。
我怎么会得到这个,我该如何解决?
完全删除<br />,您已经有一个\n数据库,当您替换为 2 新<br />行时\n:
<br />
\n
echo str_replace("<br />", "", trim($post->getContent()));