This is a discussion on PHP - BBcode within the Programming Articles forums, part of the Webmaster Articles/Tutorials category; Hell everybody Today i'm going to teach you how you can use the PHP function "str_replace()" to add bbcode to ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| | #1 (permalink) |
| WMT Addict | Hell everybody First of all, i'll show you a small little example, of how to make bold text, when a user types in [B ] and [/B ]. PHP Code: Hello, this text is Bold However, that's just a very uncomplicated use for it. Say you wanted to have something like [QUOTE ], and [/QUOTE ]. You would use something like this. PHP Code: PHP Code: Finally, i'll show you how to disallow HTML, in a submitted post. Say you didn't want to allow people to post html, because it could mess up your layout or something. You could just do this: PHP Code: I hope this was helpful for you
__________________ Kingdoms Of Battle << Check out my free to play online strategy game! SomeCoders - Coding blog, coding tips |
| | |
| | #2 (permalink) |
| Cool Newbie | Actually, I'll be mean and critisize your ideas. First off, what if someone decided to just put a , and not finish it with a ? Then the whole rest of your page would be bold, completely recking it. This is why most BBCode systems use pattern replacing instead of straight out string replacing. Second, your html break codes could be simplified by using the nl2br() function. Third, you should A: put your html remover before all of your bbcode is replaced, and B: The removing of the tags -- and a bunch of other stuff -- can be simplified with the htmlentities() function. That's all, folks. |
| | |
| | #3 (permalink) |
| WMT Addict | And there goes tim ruining my tuts as always :P
__________________ Kingdoms Of Battle << Check out my free to play online strategy game! SomeCoders - Coding blog, coding tips |
| | |
| Tags |
| bbcode, php |
| Thread Tools | |
| Display Modes | |
| |