Php / html自动在textarea中添加br标签 [英] Php/html auto add br tags in a textarea

查看:403
本文介绍了Php / html自动在textarea中添加br标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单中的文本区域,这将进入一个php脚本,将文本输出到一个文本文件中



我怎样才能让断行时间用户点击输入,换行符我的意思是
标签,这是因为文本文件是由另一个PHP脚本读取的,它将它回显到文档中。我希望它记录用户换行符(当用户点击进入时)类似于我现在使用的文本区域如何进行。我该怎么做?


EX:

嗨(输入)< br>

我是jaydman2102(输入)< ; br>

I have a text area in a form this goes into a php script that outputs the text into a text file

How can i make line breaks ever time the user hits enter, by line breaks i mean the
tag, this is because the text file is read by another php script that echoes it into the document. I want it to record the users line breaks(When the user hits enter) Similar to how the text area i am using now does it. How can i do this?

EX:
Hi(enter)<br>
I am jaydman2102(enter)<br>

推荐答案

Jaydman问:

快速提问:什么是xhtml的目的除了让代码看起来更好外还有什么优势吗?

Quick side question: What is the purpose of xhtml does it have any advantages besides making you code look better?

巨大的优势:你可以使用任何XML解析器验证代码是否正确。



实际上,即使你的文档类型是HTML而不是XHTML,你甚至不应该想要编写一些格式不正确的HTML代码。以快速但草率的方式工作并不能带来回报。在我看来,原始HTML(与XML相比)的松散是一个相当大的设计错误。在现实生活中,编写这样松散的HTML没有任何实际意义;除了潜在的麻烦,你不会得到任何东西。



我建议的一种可能的技术:将所有文件创建为XHTML,在键入时验证它们,最后,您可以将它们重命名为HTML 。



-SA

Huge advantage: you can validate that the code is correct using any XML parser.

Actually, you should not even play with the idea of writing some HTML code which is not well-formed XML, even if your document type is HTML and not XHTML. Working in a quick but sloppy way does not pay off. The looseness of original HTML (as compared with XML) was a considerable design mistake, in my opinion. In real life, writing such loose HTML makes no practical sense; you would not gain anything except potential troubles.

One of the possible techniques I would recommend: create all files as XHTML, validate them as you type, and, at the very end, you can rename them to HTML.

—SA


标签< br /> ; 仅适用于HTML。文本区域内的文本实际上不是HTML,它被视为纯文本。您需要插入换行字符。请参阅: http://en.wikipedia.org/wiki/Newline [ ^ ]。



如你所见,分隔符取决于平台(这是对那些不同平台的创建者以及未能就某些标准达成一致的社区的耻辱)。幸运的是,不错的浏览器了解在不同平台上使用的分隔符。



-SA
The tag <br/> works only for HTML. The text inside a text area is not really HTML, it is treated as a plain text. You need to insert new line character(s) instead. Please see: http://en.wikipedia.org/wiki/Newline[^].

As you can see, the delimiter is platform-dependent (and this is a shame of creators of those different platforms and the community who failed to agree on some standard). Fortunately, decent browsers understand separators used on different platforms.

—SA


这篇关于Php / html自动在textarea中添加br标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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