Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将textarea中的html标记转换为富文本_Php_Javascript_Html_Textarea - Fatal编程技术网

Php 将textarea中的html标记转换为富文本

Php 将textarea中的html标记转换为富文本,php,javascript,html,textarea,Php,Javascript,Html,Textarea,我正在使用PHP填充文本区域: <textarea text-input" id="Desc" rows="15" wrap="soft" name="Desc"><?php echo $Desc; ?></textarea> 无法在textarea内进行HTML格式化,您必须使用ant editor,但是如果您想在div中显示它,那么设置属性contentEditable=“true”就可以了 更多参考资料(已在stackoverflow上询问)为此,您

我正在使用PHP填充文本区域:

<textarea text-input" id="Desc" rows="15" wrap="soft" name="Desc"><?php echo $Desc; ?></textarea> 

无法在textarea内进行HTML格式化,您必须使用ant editor,但是如果您想在div中显示它,那么设置属性contentEditable=“true”就可以了


更多参考资料(已在stackoverflow上询问)

为此,您应该使用基于javascript的所见即所得HTML编辑器,如和

否则HTML代码将保持原样(纯文本)

但是如果您使用编辑器,用户将能够编辑内容,并且内容将使用javascript转换为富文本(这正是编辑器神奇地为您所做的)


所见即所得=所见即所得

您应该使用此处的代码


如果只想显示HTML输出,请使用
div
标记而不是
textarea
。因为,我们无法在
textarea
中显示呈现的HTML

如果要显示HTML输出并希望其可编辑,请在
div
标记上使用
contenteditable
属性

有关
contenteditable
及其支持的更多信息,请访问

<b>Analog And Digital System</b><br />
<b>Analog System:</b><br />
A string tied to a doorknob would be an analog system. They have a value that changes steadily over time and can have any one of an infinite set of values in a range. If you put a measuring stick or ruler at a specific point along the string, you can measure the string's value every so many seconds at that point. When you watch it move, you will see it moves constantly. It doesn't instantly jump up and down the ruler. <br />
<br />
<b>Digital System:</b><br />
A digital system would be to flick the light switch on and off. There's no 'in between' values, unlike our string. If the switch you are using is not a dimmer switch, then the light is either on, or off. In this case, the transmitter is the light bulb, the media is the air, and the receiver is your eye. This would be a digital system.<br />
<?  
   $text = "Hello <br /> Hello again <br> Hello again again <br/> Goodbye <BR>";
   $breaks = array("<br />","<br>","<br/>");  
   $text = str_ireplace($breaks, "\r\n", $text);  
?>  
<textarea><? echo $text; ?></textarea>