search

Home  >  Q&A  >  body text

javascript - Using thinkphp3.2.3, the textarea has been manually entered and the line feed is entered, but after submission, the database does not have any line feed tags. How to solve it?

Using thinkphp3.2.3, the textarea has been manually entered and newlined, but after submission, the database does not have any newline tags. How to solve it?

PHP中文网PHP中文网2829 days ago728

reply all(3)I'll reply

  • 某草草

    某草草2017-05-16 13:17:21

    Add <pre>

    when the page is displayed
    <pre>{$content}</pre>

    As shown in the picture

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 13:17:21

    nl2br($str);

    Convert the newline character to <br> and then store it in the database

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 13:17:21

    The space (r) and newline character (n) in the textarea do not display labels in the database. You can use them when displaying the page

    <pre>{$content}</pre>

    But if a line of content is too long, it will not automatically wrap. You can also convert the textarea's line wrapping to

    when displaying.
    str_replace("\n", "<br>", $content4);

    In this way, the output content will have line breaks.

    reply
    0
  • Cancelreply