Jump to content

PHP </textarea> in a textarea.


Speedysnail6

Recommended Posts

Hi. I don't know how to have the code </textarea> INSIDE of a textarea using PHP.

$edit_content_de = "<textarea>Text</textarea>asd";     
<p><?php echo '<textarea name="content" id="codeTextarea" style="width:90%; height:500px;">'. $edit_content_de; .'</textarea>'; ?></p>

But obviously what happens is the textarea ends and BELOW the textarea it says "asd". How do I stop this and have it say </textarea> INSIDE textarea instead of closing it?

Link to comment
https://forums.phpfreaks.com/topic/283250-php-in-a-textarea/
Share on other sites

all text content (anything that isn't html/javascript/css) should be passed through htmlentities() before being output on a web page, so that any html entities in it are converted to their character equivalents.

 

when these are submitted, they will be converted back to the actual html entities.

Link to comment
https://forums.phpfreaks.com/topic/283250-php-in-a-textarea/#findComment-1455310
Share on other sites

So you want to have the literal words in there? Use the html characters instead

<?php $edit_content_de = "<textarea>Text</textarea>asd"; ?>
<p><?php echo '<textarea name="content" id="codeTextarea" style="width:90%; height:500px;">'.$edit_content_de.'</textarea>'; ?></p>
Link to comment
https://forums.phpfreaks.com/topic/283250-php-in-a-textarea/#findComment-1455313
Share on other sites

 

So you want to have the literal words in there? Use the html characters instead

 

<?php $edit_content_de = "&lt;textarea&gt;Text&lt;/textarea&gt;asd"; ?><p><?php echo '<textarea name="content" id="codeTextarea" style="width:90%; height:500px;">'.$edit_content_de.'</textarea>'; ?></p>

or

htmlentities

Link to comment
https://forums.phpfreaks.com/topic/283250-php-in-a-textarea/#findComment-1455315
Share on other sites

A couple things:

 

1. No need to put your hard coded textarea tags int he echo

2. As mac_gyver and mentalist stated above, you should use htmlentities instead of trying to figure out the conversions yourself.

<?php
$edit_content_de = "<textarea>Text</textarea>asd";     
?>
<p><textarea name="content" id="codeTextarea" style="width:90%; height:500px;"><?php echo htmlentities($edit_content_de); ?></textarea></p>
Link to comment
https://forums.phpfreaks.com/topic/283250-php-in-a-textarea/#findComment-1455318
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.