Cremnlin Posted July 23, 2010 Share Posted July 23, 2010 I'm wondering how I should go about displaying some code in plain text without it actually performing what the code does. Specifically, I'm trying to display some youtube embeds as just text. Link to comment Share on other sites More sharing options...
dsonesuk Posted July 23, 2010 Share Posted July 23, 2010 just use < and > as in <span style="color:red;">THIS IS TEST</span> would now be <span style="color:red;">THIS IS TEST</span>, which is treated as text instead of html code. Link to comment Share on other sites More sharing options...
Cremnlin Posted July 23, 2010 Author Share Posted July 23, 2010 Thanks, another thing, though. I'm withdrawing this code from a database, so the only thing I can think of is writting some php code that replaces the mentioned characters with things like '<'. I guess I should have posted this in the php section, then, but is there a special function that does this in php? Link to comment Share on other sites More sharing options...
dsonesuk Posted July 23, 2010 Share Posted July 23, 2010 just use str_replace() as in$textcode = str_replace("<","<", $row['htmlcode']); //changes code from table field name htmlcode$textcode = str_replace(">",">", $textcode); // converts remaining code passed to $textcode Link to comment Share on other sites More sharing options...
jeffman Posted July 23, 2010 Share Posted July 23, 2010 See also htmlspecialchars or htmlentities Link to comment Share on other sites More sharing options...
dsonesuk Posted July 23, 2010 Share Posted July 23, 2010 or better still use htmlentities($str); does exactly the same in one instance;echo htmlentities($row['htmlcode']); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.