php :: textarea中的新行? [英] php :: new line in textarea?

查看:90
本文介绍了php :: textarea中的新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过php插入文本时,如何在textarea中创建新行?

How do you create a new line in a textarea when inserting the text via php?

我以为是\n,但实际上是打印在文本区域中的.

I thought it was \n but that gets literally printed in the textarea.

谢谢

推荐答案

我不确定不能看到您的代码,但是我猜您正在使用单引号('\ n')而不是双引号("\ n" ).

Without seeing your code I cannot be sure, but my guess is you are using single quotes ('\n') instead of double quotes ("\n").

仅当字符串用双引号引起来时,PHP才会评估转义序列.如果您使用'\ n',PHP会将其作为文字字符串.如果您使用"\ n",PHP将解析该字符串以获取变量和转义序列,并按您的期望打印新行.

PHP will only evaluate escape sequences if the string is enclosed in double quotes. If you use '\n', PHP will just take that as a literal string. If you use "\n", PHP will parse the string for variables and escape sequences and print a new line like you are expecting.

这篇关于php :: textarea中的新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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