BBCode class documentation

This class can be used to convert BBCode style text to html.

This is standalone class whitch uses regular expression rules to parse bbcode. It is simple to use by calling only one static method and supports lots of bbcode style tags (see the table below).

Usage example:

include "BBCode.class.php";
$bbcode_text = 'Hello [b]World[/b]!';
$html_text = BBCode::parse($bbcode_text);
echo $html_text;

The output is:

Hello <strong>World</strong>!

Supported BBCode tags:

[b]{text}[/b] Makes {text} bold
[i]{text}[/i] Makes {text} italic
[u]{text}[/u] Makes {text} underlined
[s]{text}[/s] Makes {text} strike through
[size={number}]{text}[/size] Changes the font-size of {text}
[font={font-family}]{text}[/font] Changes the font-family of {text}
[color={colour}]{text}[/color] Changes the colour of {text}
[center]{text}[/center] Centers {text} on page
[align={left|center|right}]{text}[/align] Aligns {text} on page to left, center or right
Makes a link or named link to {url}
Makes na e-mail link or named e-mail link to {email}
[bull /] Outputs bullet: •
[copyright /] Outputs "copyright" symbol: ©
[registered /] Outputs "registered" symbol: ®
[tm /] Outputs "trademark" symbol: ™
Shows the image indicated by {url}
Shows {url} image resized to {width} and {height}
[img width={width} height={height} ...]{url}[/img] Shows {url} image with additional metainformation. You can add attributes supported by the HTML <img> tag. Eg.: width, height, alt, align, etc.
Creates a quotation box containing {text} or quotation box quoting {name} as saying {text}
[code]{text}[/code] Outputs {text} to a preformatted text block

List items:

Displays a list of {items}
  [*] Item one
  [*] Item two
  [li]Item one[/li]
  [li]Item two[/li]
Possible {list-style} values:
none, disc, circle, square, decimal, decimal-leading-zero, lower-roman, upper-roman, lower-greek, lower-alpha, lower-latin, upper-alpha, upper-latin, hebrew, armenian, georgian, cjk-ideographic, hiragana, katakana, hiragana-iroha, katakana-iroha
Makes {text} subscript
[sup]{text}[/sup] Makes {text} superscript
[p]{text}[/p] Outputs {text} to a paragraph block
Shows the youtube video indicated by {id}
[gvideo]{id}[/gvideo] Shows the google video indicated by {id}