Misc Links
Forum Archive
News Archive
File DB



Latest Forum Topics
wow 56 k modems are
Posted by Red Squirrel
on Oct 14 2013, 11:52:23 pm

I Need A Program
Posted by rovingcowboy
on Sep 23 2013, 5:37:59 pm

having trouble witn lan
Posted by rovingcowboy
on Sep 23 2013, 5:40:56 pm

new problem for me
Posted by rovingcowboy
on Sep 23 2013, 5:54:09 pm

RBC Royal Bank
Posted by Red Squirrel
on Aug 13 2013, 6:48:08 pm


BBcode editor: PHP - The sensible approach
More with bbcode
By Jonathan Street

Iíll skip over setting PEAR up and fetching the HTML_BBCodeParser package and get straight into the actual use of the package.

First of all weíll set up a form so that we can submit BBcode formatted text for conversion to html.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

    <textarea name="bbcode">
        <?php echo @$_POST['bbcode']; ?>


In the same file, and I suggest at the top, you want to add the following code to handle the bbcode.

if (!empty($_POST['bbcode'])) {
    //bbcode has been submitted through the text area
    //Process it
    require_once 'HTML/BBCodeParser.php';
    $parser = new HTML_BBCodeParser();
    echo $parser->getParsed();

This code block checks whether text has been submitted and if it has it creates an instance of the HTML_BBCodeParser class. It then uses three functions to get the text to be parsed, parse the text and then to return it. These three functions can be wrapped up into one function and Iíll use the faster method from now on. Before proceeding however a quick note on what this script is capable of doing. At present it is fairly limited. HTML_BBCodeParser is based around filters making it possible to create custom bbcode tags and significantly extend its capabilities. The reason why the above script can so far only handle bold, italic, underline, strikethrough, subscript and superscript is that only the first filter, Basic, is being used. To use other filters a configuration file is needed.


; possible values: single|double
; use single or double quotes for attributes
quotestyle  = double

; possible values: all|nothing|strings
; quote all attribute values, none, or only the strings
quotewhat   = all

; the opening tag character
open        = "["

; the closing tag character
close       = "]"

; possible values: true|false
; use xml style closing tags for single html tags (<img> or <img />)
xmlclose    = true

; possible values: a comma seperated list of filters
; comma seperated list of filters to use
filters     = Basic,Extended,Links,Images,Lists,Email

This is the complete configuration file Iím using but we only really need to discuss the last line dealing with the filters. Listed are the five filters that are supplied with HTML_BBCodeParser. To make use of this increased functionality we need to alter the code used previously.

if (!empty($_POST['bbcode'])) {
    //bbcode has been submitted through the text area
    //Process it
    require_once 'HTML/BBCodeParser.php';
    $parser = new HTML_BBCodeParser(parse_ini_file('BBCodeParser.ini'));
    echo $parser->qParse($_POST['bbcode']);

When instantiating the new HTML_BBCodeParser class we supply options by parsing the configuration ini file. This then allows us to use the full set of filters supplied.

Next Page
25531 Hits Pages: [1] [2] [3] 2 Comments

Latest comments (newest first)
Posted by Streety on August 08th 2006 (14:37)
What can I say richardj, I've learnt a lot since the first two articles.

I've just made a new post on my blog looking in detail at Text_Wiki_BBCode. It has some potential uses but HTML_BBCodeParser would still be my pick.

Posted by richardj on August 08rd 2006 (19:10)
QUOTE (Red Squirrel @ Aug 2 2006, 07:35 PM)
In truth, as complex as I thought the problem was, in reality it was probably more complex still.


user posted image em319.gif

View all comments
Post comment

Top Articles Latest Articles
- What are .bin files for? (669062 reads)
- Text searching in linux with grep (161180 reads)
- Big Brother and Ndisuio.sys (150471 reads)
- PSP User's Guide (139547 reads)
- SPFDisk (Special Fdisk) Partition Manager (117240 reads)
- How to Use MDADM Linux Raid (188 reads)
- What is Cloud Computing? (1225 reads)
- Dynamic Forum Signatures (version 2) (8769 reads)
- Successfully Hacking your iPhone or iTouch (18714 reads)
- Ultima Online Newbie Guide (35906 reads)
corner image

This site best viewed in a W3C standard browser at 800*600 or higher
Site design by Red Squirrel | Contact
© Copyright 2020 Ryan Auclair/IceTeks, All rights reserved