Jump to content

[SOLVED] Parsing HTML tags


play_

Recommended Posts

From a blog entry, php echoes this line to the browser:

 

<Directory /media/Shared/sites/www/subdomains/expyred/>

 

It doesn't show, because HTML tries to parse it, i believe.

Which means i have to convert < into >, etc.

 

However, when typing the blog, i do insert html characters such as <b> and <u>, etc.

 

What is the simplest way I could I make it so any HTML tags get parsed, but non-html tags don't?

 

Do i have to resort to bbcode?

Link to comment
https://forums.phpfreaks.com/topic/172559-solved-parsing-html-tags/
Share on other sites

That would be an idea, or have an array of tags, such as

 

I don't know if this would work, but give it a try

 

$Input = preg_replace('~(<[^bui]+)>~', '>$1>', $Input);

 

But that would still only work for things that are just <b> or <u> or <bbb> or such. BBCode is best really.

 

But that's just me, there's probably a better answer

Hrmmm, instead of a fullout BBCode system, you could have a htmlentities BBCode.

 

 

It would be pretty ghetto, but you could do something like:

 

[htmlentities]<Directory /media/Shared/sites/www/subdomains/expyred/>[/htmlentities]

 

Then server side:

 

 

$str = preg_replace('/\[htmlentities\](.*?)\[\/htmlentities\]/ie', "htmlentities('\1')");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.