How do i display html tags as plain text in php?
I have an input form on my website where HTML is allowed and I'm trying to add instructions about the use of HTML tags. I'd like the text to Show
But so far all I get is: Look just like this line - so then know how to type it How can I show the tags so people know what to type?
falsarella 12.1k9 gold badges69 silver badges113 bronze badges
asked Jul 25, 2011 at 13:58
0 Replace
isherwood 54.2k15 gold badges105 silver badges147 bronze badges answered Jul 25, 2011 at 14:00
DarmDarm 5,4512 gold badges19 silver badges18 bronze badges 4 In PHP use the function htmlspecialchars()
to escape
answered Jul 25, 2011 at 14:02
acmeacme 14.3k7 gold badges73 silver badges106 bronze badges 0 As many others have said, Wrap it up with a
answered Mar 25, 2013 at 22:05
JarrodJarrod 9,2015 gold badges57 silver badges72 bronze badges 0 You should use
KetZoomer 2,4763 gold badges13 silver badges37 bronze badges answered Jul 25, 2011 at 14:00
Luiz DamimLuiz Damim 3,6932 gold badges26 silver badges31 bronze badges you may use htmlspecialchars()
answered Oct 29, 2013 at 13:19
Nikunj K.Nikunj K. 8,2814 gold badges41 silver badges51 bronze badges You just need to encode the
answered Jul 25, 2011 at 14:00
James MontagneJames Montagne 76.2k14 gold badges108 silver badges129 bronze badges To display HTML tags within a browser, surround the output with < xmp> and < / xmp> tags answered Jun 22, 2014 at 14:38
Paulo HenriquePaulo Henrique 8281 gold badge13 silver badges18 bronze badges 2 You can use htmlentities when echoing to the browser, this will show the tag rather than have html interpret it. See here http://uk3.php.net/manual/en/function.htmlentities.php Example:
Output:
answered Jul 25, 2011 at 14:03
martynthewolfmartynthewolf 1,6881 gold badge11 silver badges22 bronze badges
answered Apr 18, 2019 at 12:30
Simon BorskySimon Borsky 4,6112 gold badges20 silver badges17 bronze badges 2 There is another way...
This makes the whole page served as plain text... better is htmlspecialchars... Hope this helps... answered Sep 1, 2018 at 12:06
AlessandroAlessandro 8429 silver badges23 bronze badges Use htmlentities() to convert characters that would otherwise be displayed as HTML. answered Jul 25, 2011 at 14:03
ReubenReuben 4,0162 gold badges43 silver badges56 bronze badges 0 Can we use HTML tags in PHP?As you can see, you can use any HTML you want without doing anything special or extra in your PHP file, as long as it's outside and separate from the PHP tags. In other words, if you want to insert PHP code into an HTML file, just write the PHP anywhere you want (so long as they're inside the PHP tags).
How do I display HTML code without executing?Use HTML Special Character Codes
var myCode = "This is not bold"; $('span#code-span'). text(myCode); Using text instead of html will cause tags to be rendered exposed instead of being executed.
How do I view the HTML code of a website?To view only the source code, press Ctrl + U on your computer's keyboard. Right-click a blank part of the web page and select View source from the pop-up menu that appears.
How do I render HTML tags from mysql database in PHP?The only way to display the html content is to simply echo $row3['description'] , however, this leaves you open to vulnerabilities and unless you really trust the data (ie: never) then you should clean it up first. You can try htmlpurifier for this. Show activity on this post.
|