Hello All ,
# This is simple topic about bbcode , let's start .
Intro :
Did you post in any forum like phpbb ? , Did you make some words bold , underline , ... ?
Have you post images in phpbb form ?
# If your answer is yes , So congratulation ! you have used bbcode . You may ask now " what is bbcode ? , " why bbcode ?" , how ? . here is the answers .
What is bbcode ?:
First bbcode is a short for bulletin board code , also called forum codes . It is lightweight markup language used to format posts in many message boards , also used in guestbooks , blogs ,...etc .
BBcode tage are usually surrounded by rectangular brackets , it is similar to HTML . They are parsed by script that translate it to simple HTML or XHTML that browser understand .
this is similar to this :
wow , they are similar . So you may ask why do we use bbcode instead of HTML ?
Why use BBcode ?:
Before bbcode forums sometimes allow user to include html code in their posts which has many security issues (user can execute JavaScript code ,they can break page layout and so on , also may lead to XSS attacks ) .
BBcode provide more safer , easier and more limited way of allowing users format their posts . BBcode is parsed by forum scripts , so it is more easy to control what user can do and can not do . Many boards like phpbb allow admin to disable , add new bbcodes .
BBcode tags :
you can see list of bbcode tags and how to use here :
http://www.bbcode.org/tags.php
http://www.phpbb.com/community/faq.php?mode=bbcode
How To :
While coding there are two types of bbcode simple and complex :
1# simple bbcode
This techinque for simple bb code can be used to easily replace tags with no attributes like the bold and italic tags.
Two arrays are defined one for the bb code and another one for the html that will replace the bbcode and then the str_replace function is used to replace the html text for the bbcode in the string.
The same technique may also be used for things such as creating a swear filters, smilies and emoticons etc..
2# Complex bbcode :
The previous technique for creating bb code works well for things like bold and italic tags, but its not good for creating more complex things like bb code for hyperlinks or image tags.
# to know more about this :
http://www.tutorio.com/tutorial/simple- ... -with-php/
Refrences:
http://en.wikipedia.org/wiki/BBCode
http://www.bbcode.org/
http://bb.bbboy.net/man/BbCode.html
http://www.phpbb.com/community/faq.php?mode=bbcode
http://www.askdavetaylor.com/what_is_bb ... se_it.html
http://www.tutorio.com/tutorial/simple- ... -with-php/
see this also :
http://www.bbcode-to-html.com/
http://corpocrat.com/2008/08/15/free-wy ... avascript/
Thanks in Advance !
# This is simple topic about bbcode , let's start .
Intro :
Did you post in any forum like phpbb ? , Did you make some words bold , underline , ... ?
Have you post images in phpbb form ?
# If your answer is yes , So congratulation ! you have used bbcode . You may ask now " what is bbcode ? , " why bbcode ?" , how ? . here is the answers .
What is bbcode ?:
First bbcode is a short for bulletin board code , also called forum codes . It is lightweight markup language used to format posts in many message boards , also used in guestbooks , blogs ,...etc .
BBcode tage are usually surrounded by rectangular brackets , it is similar to HTML . They are parsed by script that translate it to simple HTML or XHTML that browser understand .
- CODE: SELECT ALL
[b]text[/b]
this is similar to this :
- CODE: SELECT ALL
<b>text</b>
wow , they are similar . So you may ask why do we use bbcode instead of HTML ?
Why use BBcode ?:
Before bbcode forums sometimes allow user to include html code in their posts which has many security issues (user can execute JavaScript code ,they can break page layout and so on , also may lead to XSS attacks ) .
BBcode provide more safer , easier and more limited way of allowing users format their posts . BBcode is parsed by forum scripts , so it is more easy to control what user can do and can not do . Many boards like phpbb allow admin to disable , add new bbcodes .
BBcode tags :
you can see list of bbcode tags and how to use here :
http://www.bbcode.org/tags.php
http://www.phpbb.com/community/faq.php?mode=bbcode
How To :
While coding there are two types of bbcode simple and complex :
1# simple bbcode
This techinque for simple bb code can be used to easily replace tags with no attributes like the bold and italic tags.
- CODE: SELECT ALL
$string = "I am so [b]cool[/b] " ;
$bb-replace = array('[b]','[/b]','[i]',[/i]);
$bb-replacements = array ('','','','');
$string = str_replace($bb-replace,$bb-replacements,$string);
Two arrays are defined one for the bb code and another one for the html that will replace the bbcode and then the str_replace function is used to replace the html text for the bbcode in the string.
The same technique may also be used for things such as creating a swear filters, smilies and emoticons etc..
2# Complex bbcode :
The previous technique for creating bb code works well for things like bold and italic tags, but its not good for creating more complex things like bb code for hyperlinks or image tags.
- CODE: SELECT ALL
$string = "This is [b]cool[/b] - [url=http://www.tutorio.com]Tutorio.com Tutorials[/url] " ;
$bb-replace = array ('/(\[[Bb]\])(.+)(\[\/[Bb]\])/','/(\[url=)(.+)(\])(.+)(\[\/url\])/');
$bb-replacements = array ('<b>\\2</b>','<a href="\\2">\\4</a>');
$string = preg_replace($bb-replace, $bb-replacements, $string);
print $string;
# to know more about this :
http://www.tutorio.com/tutorial/simple- ... -with-php/
Refrences:
http://en.wikipedia.org/wiki/BBCode
http://www.bbcode.org/
http://bb.bbboy.net/man/BbCode.html
http://www.phpbb.com/community/faq.php?mode=bbcode
http://www.askdavetaylor.com/what_is_bb ... se_it.html
http://www.tutorio.com/tutorial/simple- ... -with-php/
see this also :
http://www.bbcode-to-html.com/
http://corpocrat.com/2008/08/15/free-wy ... avascript/
Thanks in Advance !





Comments
Write New Comment ▼
Write New Comment
Sorry! This knol's owner(s) have blocked you from editing, making suggestions, or commenting here.