prolife Posted September 16, 2013 Share Posted September 16, 2013 (edited) Hi guys i typed and saved som text from my admin page, i tried displaying it in my home page but it has some html a nd some styles inlcuded, please how do i convert it to plain text, i already used htmlspecialchars and htmlentities , i noticed some.changes but what i want to is a plain text. This is what it gave me when i viewed it with "htmlspecialchars" <font face="Times New Roman"><b><font size="5">You Are welcomevv</font></b></font> and here is the code i used in displaying-: echo htmlspecialchars($object->data['page-body']) ; Please i need your help. Thanks. Edited September 16, 2013 by prolife Quote Link to comment https://forums.phpfreaks.com/topic/282193-html-is-messing-up/ Share on other sites More sharing options...
requinix Posted September 16, 2013 Share Posted September 16, 2013 Don't use htmlspecialchars(). Or anything. Just output it directly. You have to do that because for some silly reason your data contains HTML markup. Quote Link to comment https://forums.phpfreaks.com/topic/282193-html-is-messing-up/#findComment-1449739 Share on other sites More sharing options...
Irate Posted September 16, 2013 Share Posted September 16, 2013 htmlspecialchars does what the name suggests, it converts HTML control characters (<, >, ', ") into their HTML4 entities... which are generally universally supported if you display them. But, as requinix hinted above, why would you escape HTML control characters if you actually want to use HTML? Oh, by the way, <font> is deprecated. Don't use it. Quote Link to comment https://forums.phpfreaks.com/topic/282193-html-is-messing-up/#findComment-1449774 Share on other sites More sharing options...
prolife Posted September 17, 2013 Author Share Posted September 17, 2013 Guys, you dont seem to understand. Let me break it down. I have an Admin pannel where i can edit certain pages on my site, now my admin pannel has a text editor which enables me to make my text bold, change clolour etc.So saving a bold text for instance will look something like this<strong> My text </strong>. Now my question is how do i display this formated text so that it reatains the alteratio; bold for instance without displaying the HTML. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/282193-html-is-messing-up/#findComment-1449854 Share on other sites More sharing options...
Solution dungpt29 Posted September 17, 2013 Solution Share Posted September 17, 2013 Hi prolife, I guess that you are trying to save the formatted text from a text editor into your database. Then you want to display it on your webpage as plain text. You should try the following PHP function and it worked for me: <?php echo html_entity_decode("data pulled out from database")?> Quote Link to comment https://forums.phpfreaks.com/topic/282193-html-is-messing-up/#findComment-1449865 Share on other sites More sharing options...
prolife Posted September 17, 2013 Author Share Posted September 17, 2013 (edited) thanks to everyone who viewed and contributed,@dongpt29,thanks a whole lot; im grateful Edited September 17, 2013 by prolife Quote Link to comment https://forums.phpfreaks.com/topic/282193-html-is-messing-up/#findComment-1449930 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.