0

Here I need to display text with break line but I simply display the html code inside the text area. Here is my code

<?php
$msg.="From :";
$msg.="<br/>";
$msg.="To :";
$msg.="Date :";
print_r($msg);
?>
<textarea><?php print_r($msg);?></textarea>

I need to print html executed code in text area. Thank you in advance.

1
  • use echo: echo $msg Commented May 26, 2017 at 13:15

3 Answers 3

4

HTML way to fix it, use ASCII characters &#013; &#010;.

Carriage return &#013;

Line feed &#010; (HTML entity: &NewLine;)

REF: http://www.theasciicode.com.ar/ascii-control-characters/carriage-return-ascii-code-13.html

<textarea cols='60' rows='8'>This is line1&#13;&#10;This is line2</textarea>

Sign up to request clarification or add additional context in comments.

Comments

0

Just replace your code from:

<textarea><?php print_r($msg);?></textarea>

to:

<textarea><?php echo $msg;?></textarea>

Comments

0

You could try something like:

echo '<textarea>'.print_r($msg).'</textarea>';

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.