This is a discussion on "<code> tags" within the PHP Forum section. This forum, and the thread "<code> tags are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
<code> tags
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
<code> tags
Hi all,
I've written a CMS for my blog site, and I'm trying to write a simple tutorial. However, I can't work out how to add html code to the page without the engine rendering it as html. So for example if I type into my blog post box...
But what if I wanted this to display as code as typed above in my post without it actually rendering the html? |
|
|
|
#2
|
|||
|
|||
|
Re: <code> tags
Quote:
htmlspecialchars takes a string and replaces the symbols < > & ' " with their HTML representation, i.e. < becomes < htmlentities is more general in that it replaces all symbols in a string with the HTML entities. For example € becomes € and £ becomes £ So, to display a string as code you just write
|
|
#3
|
|||
|
|||
|
Re: <code> tags
Yes you understand what I mean.
But my porblem is... Basically my CMS allows me to type the text for the post into a textbox. As I am doing right now in this post. And here you use [ code ] and [ /code ] and anything in that bracket will be displayed correctly. I need a similar thing. If I post this in my blog:
do you understand? |
|
#4
|
|||
|
|||
|
Re: <code> tags
Have you tried the code element?
Like this:
Pete. |
|
#5
|
|||
|
|||
|
Re: <code> tags
That doesn't work, I just tried it.
Pete. |
|
#6
|
|||
|
|||
|
Re: <code> tags
Use the funny symbols. &alt; etc. That should work.
Pete. |
|
#7
|
|||
|
|||
|
Re: <code> tags
yea I have done that now.
its a bugger though. Cos when I go to edit the post, it replaces all the funny symbols with what they represent so I have to go through replacing them all again! |
|
#8
|
|||
|
|||
|
Re: <code> tags
A combination is probably best.
Like this:
Hope that works, Pete. |
|
#9
|
|||
|
|||
|
Re: <code> tags
Thanks Pete thats excellent!
I've still got the problem that when I then go back in to edit it, the
if anyone knows how I can combat this please speak up! To explain how it works... I enter the post in a form...it is sent and stored in mySQL db. When I go to edit it it is retrieved from the db and displayed in the form fields using GET queries. So...there ya go! Mike |
|
#10
|
|||
|
|||
|
Re: <code> tags
I would imagine you'll have change your cms in some way though I'm not sure how. It is also very irritating just writing those < things out. The example above took me ages.
I wonder how they do it on forums, I know forums are pretty complex but someone must know how it's done. Pete. |
|
#11
|
|||
|
|||
|
Re: <code> tags
I had the same problem with my custom CMS
When you go to edit, display the content with the htmlentities() function hschmitz told you about |
|
#12
|
|||
|
|||
|
Re: <code> tags
Cool thanks Karrine works brilliantly. I thought it might cancel out all html tags but it only does those between the code tags! Excellent.
|
![]() |
| Tags |
| code php html |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Title Tags, Meta Tags and SEO - Keyword Density or Keyword Spamming? | pctank | Search Engine Optimization (SEO) | 2 | Jul 4th, 2008 11:52 |
| alt tags in css | multichild | Web Page Design | 1 | Feb 24th, 2008 12:35 |
| code behind code doesnt work | skat | ASP.NET Forum | 4 | Feb 18th, 2008 10:05 |
| live search code and styleswitcher code | hebel | JavaScript Forum | 0 | May 12th, 2007 06:16 |
| Can somebody give me the code to hide the source code? | renren | JavaScript Forum | 7 | Mar 7th, 2006 12:27 |