jeff5656 Posted May 3, 2011 Share Posted May 3, 2011 In a text box I put in some code snippets that I want to refer to later, but when I display it, it displays it in html. How do I convert the code into pure text so it displays the actual code? If I try strip_tags, that just strips it (and it doesn't work with php). And I can't use strip_tags with conditions, because I don't want to list all codes! Also, the code has both html tags and php code - I just want that whole thing to be displayed as is, without havign the browser try to "read" it. Also if I put this into the text box, <td><?php echo date ("m/d/Y", strtotime($row['code_date']));?></td> then nothing is displayed. If I put this in the box: <input class="button" style="display:inline" name="whatever" type="submit" value="Press here" /> then I get an actual submit button instead of the code! Quote Link to comment https://forums.phpfreaks.com/topic/235425-convert-html-tags-to-text/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 3, 2011 Share Posted May 3, 2011 Use htmlentities with the second parameter set to ENT_QUOTES. Or if you want the code color highlighted when you output it - highlight_string Quote Link to comment https://forums.phpfreaks.com/topic/235425-convert-html-tags-to-text/#findComment-1209900 Share on other sites More sharing options...
jeff5656 Posted May 3, 2011 Author Share Posted May 3, 2011 Beautiful. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/235425-convert-html-tags-to-text/#findComment-1209902 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.