Speedysnail6 Posted October 24, 2013 Share Posted October 24, 2013 (edited) 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 October 24, 2013 by Speedysnail6 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 24, 2013 Share Posted October 24, 2013 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. Quote Link to comment Share on other sites More sharing options...
JD* Posted October 24, 2013 Share Posted October 24, 2013 (edited) 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 October 24, 2013 by JD* Quote Link to comment Share on other sites More sharing options...
Speedysnail6 Posted October 24, 2013 Author Share Posted October 24, 2013 Thanks! Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 24, 2013 Share Posted October 24, 2013 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> or htmlentities Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 24, 2013 Share Posted October 24, 2013 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.