mktgbill Posted January 10, 2008 Share Posted January 10, 2008 Probably a simple solution to this so I'm here to ask the experts.... I'm echoing an html comment which I'd like to appear on page as text.... echo "<!" . $data . ">" Any thoughts on how to accomplish this? thanks, bill Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/ Share on other sites More sharing options...
interpim Posted January 10, 2008 Share Posted January 10, 2008 this is more of an html question, but you would have to escape the html tags Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435702 Share on other sites More sharing options...
cooldude832 Posted January 10, 2008 Share Posted January 10, 2008 http://us.php.net/manual/en/function.htmlentities.php Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435704 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 echo "<!--$data-->"; That's a HTML comment. Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435705 Share on other sites More sharing options...
kenrbnsn Posted January 10, 2008 Share Posted January 10, 2008 If you want any HTML tag to appear on the screen, you need to process it with the function htmlentities(): <?php echo htmlentities('<!-- ' . $data . ' -->',ENT_QUOTES); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435706 Share on other sites More sharing options...
cooldude832 Posted January 10, 2008 Share Posted January 10, 2008 If you want any HTML tag to appear on the screen, you need to process it with the function htmlentities(): <?php echo htmlentities('<!-- ' . $data . ' -->',ENT_QUOTES); ?> Ken On the screen could mean in source or on the outputted, either way I beat you too it Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435708 Share on other sites More sharing options...
mktgbill Posted January 10, 2008 Author Share Posted January 10, 2008 Of course as I'm typing this I've gotten 4 answers I've figured it out (and pretty stinking easy, can't believe I didn't try this before) <! <?php echo $description; ?> > like stupid easy Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435714 Share on other sites More sharing options...
kenrbnsn Posted January 10, 2008 Share Posted January 10, 2008 On the screen could mean in source or on the outputted, either way I beat you too it True, but you replied with only one line, while I gave an example and explanation. That takes longer to type. Ken Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435715 Share on other sites More sharing options...
cooldude832 Posted January 10, 2008 Share Posted January 10, 2008 If you give a man a fish he eats for a day if you teach a man to fish he eats for his life Just saying Quote Link to comment https://forums.phpfreaks.com/topic/85392-echo-an-html-comment/#findComment-435720 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.