Jump to content

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?

Edited by Speedysnail6
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>
Edited by JD*
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.