Quote HTML tags

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Shrike
Forum Newbie
Posts: 3
Joined: Thu Oct 31, 2002 3:01 am

Quote HTML tags

Post by Shrike »

I've had a look through the snippets at evil walrus but they all deal with quoting whole pages - I just want a little function which will allow me to quote html tags whenever I need to.

Anyone help?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Not sure exactly what you mean do you mind explaining a bit more what you are trying to achieve.

Mac
Shrike
Forum Newbie
Posts: 3
Joined: Thu Oct 31, 2002 3:01 am

Post by Shrike »

Well, I've noticed on evil walrus that there are snippets that give your visitors the ability to click a button and see the source of the whole page they clicked the link from - I just want to be able to quote HTML tags without using those hard to remember symbols.
I'm not sure if this can be done with client-side which is why I'm posting it here.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

OK, I think what you want to do is have things like

Code: Select all

<p><b>Hello world</b></p>
visible to the user's without have to write out all the <'s and >'s. In that case you can use PHP to convert the tags so that instead of interpreting them the browser displays them:

Code: Select all

$html = '&lt;p&gt;&lt;b&gt;hello world&lt;/b&gt;&lt;/p&gt;';
echo htmlspecialchars($html);
htmlspecialchars() will change any <'s, >'s, &'s and "'s to their entity version (<, >, &, ").

Mac
Shrike
Forum Newbie
Posts: 3
Joined: Thu Oct 31, 2002 3:01 am

Post by Shrike »

That is exactly what I wanted!

Cheers!
Post Reply