Sniffy Posted July 6, 2006 Share Posted July 6, 2006 I was wondering how to display a piece of html code as text on an html page yet don't execute it like in the w3schools tutorials.Would I use PHP or something and display my code as a variable and execute an echo like this?: <html><head><title>Test Page of Mine</title></head><body><?php $MyTest="<html><head><title>test</title></head><body>This is a basic html document.</body></html>"echo $MyTest ."That is an example of basic html" ?></body></html> Link to comment Share on other sites More sharing options...
aspnetguy Posted July 6, 2006 Share Posted July 6, 2006 you would need to replace all (<) with < and (>) with > Link to comment Share on other sites More sharing options...
pulpfiction Posted July 6, 2006 Share Posted July 6, 2006 Use < for < and > for > and the tag name go in the normal way in the middle<html></html> can be written like this <html></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 6, 2006 Share Posted July 6, 2006 If you are using PHP, you can use a built-in function. <?php $MyTest="<html><head><title>test</title></head><body>This is a basic html document.</body></html>";echo htmlentities($MyTest);?> http://www.php.net/manual/en/function.htmlentities.php Link to comment Share on other sites More sharing options...
scott100 Posted July 6, 2006 Share Posted July 6, 2006 If you are using PHP, you can use a built-in function.<?php $MyTest="<html><head><title>test</title></head><body>This is a basic html document.</body></html>";echo htmlentities($MyTest);?> http://www.php.net/manual/en/function.htmlentities.php <{POST_SNAPBACK}> Your knowledge of php is impressively endless How long have you been involved with it Link to comment Share on other sites More sharing options...
justsomeguy Posted July 6, 2006 Share Posted July 6, 2006 I think I've worked with PHP for around 3 years now, maybe a little more. But most of the tips are give are because I've run into the same thing. I can't tell you how many times I've tried to write my own function to do a certain task (like convert HTML characters to entity codes), and then realize that there is a built-in function to do exactly that. That's the great thing about PHP, since it's open source and maintained by people that actually use it, there are a lot of time-saving things built-in that web programmers commonly use.But I wouldn't say my knowledge is endless. If I had to guess, I would say I've probably been exposed to around 30% of what PHP has to offer, and out of that 30%, probably about 40-50% I can use without needing to lookup online. The rest of the time I'm researching.It's not necessary to know everything, as long as you know where to look. Link to comment Share on other sites More sharing options...
zanfranceschi Posted July 7, 2006 Share Posted July 7, 2006 And a wonderful place to look for is http://www.php.net/I see that justsomeguy always links to www.php.net when posting php functions. I bet he also thinks php.net is one of the best places to learn PHP. There always are examples on how to use functions. Link to comment Share on other sites More sharing options...
Sniffy Posted July 7, 2006 Author Share Posted July 7, 2006 you would need to replace all (<) with < and (>) with ><{POST_SNAPBACK}> Thanks fellow Nova Scotian. I would never have guest to use that code list of letters/ symbols.And thank you to the rest for contributing your knowledge. Link to comment Share on other sites More sharing options...
aspnetguy Posted July 7, 2006 Share Posted July 7, 2006 Thanks fellow Nova Scotian. I would never have guest to use that code list of letters/ symbols.And thank you to the rest for contributing your knowledge. <{POST_SNAPBACK}> no problem, but justsomeguy's solution would be far easier. Anytime I want ot display something that is a reserver char or something I resort to ASCII codes. Link to comment Share on other sites More sharing options...
Sniffy Posted July 7, 2006 Author Share Posted July 7, 2006 no problem, but justsomeguy's solution would be far easier. Anytime I want ot display something that is a reserver char or something I resort to ASCII codes.<{POST_SNAPBACK}> Okay, but I'm still new to PHP so I'm taking it slow. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 7, 2006 Share Posted July 7, 2006 And a wonderful place to look for is http://www.php.net/I see that justsomeguy always links to www.php.net when posting php functions. I bet he also thinks php.net is one of the best places to learn PHP. There always are examples on how to use functions.By definition, nothing will ever be a better PHP resource than php.net. It's a little bit technical, but it's very informative. The user comments are also helpful. It's the first place I look for questions about PHP, and my second choice is generally a book. Link to comment Share on other sites More sharing options...
Sniffy Posted July 7, 2006 Author Share Posted July 7, 2006 By definition, nothing will ever be a better PHP resource than php.net. It's a little bit technical, but it's very informative. The user comments are also helpful. It's the first place I look for questions about PHP, and my second choice is generally a book.<{POST_SNAPBACK}> Well, I'll keep it in mind. I'm getting better than PHP by the minute. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now