Git Product home page Git Product logo

php-bbcode's Introduction

Instructions

  1. Include bbcode.php
  2. Instantiate the BBCode class
  3. Execute the toHTML method on a string which contains BBCode (optionally pass true as the second argument to escape special html chars first)
  4. Enjoy HTML output

Example Code

<?php
require "bbcode.php";

$text=<<<EOF

[b]This is bold text[/b]

[i]This is italic text[/i]

[code]This is pre-formatted text[/code]

[quote]This is a quote[/quote]

[quote="Obama"]This is a quote by a specific person[/quote]

[size=30]This text's size is set at 30%[/size]

[s]This text has a strikethrough[/s]

[u]This text is underlined.[/u]

[center]This text is centered[/center]

[color=red]This is red text[/color]

[email][email protected][/email]

[[email protected]]An e-mail link[/email]

[url]http://www.google.com/[/url]

[url=http://www.google.com/]Google.com yo![/url]

[img]http://i.imgur.com/WqYEO.jpg[/img]

An image as a link:

[url=http://en.wikipedia.org/wiki/Ninja][img]http://i.imgur.com/8d7Yu.jpg[/img][/url]

This is an unordered list: 

[list]
[*]list item #1
[*]list item #2
[*][b]bold list item #3[/b]
[/list]

This is an ordered (numbered) list: 

[list=1]
[*]list item #1
[*]list item #2
[*][b]bold list item #3[/b]
[/list]

This is an ordered (alpha) list: 

[list=a]
[*]list item #1
[*]list item #2
[*][b]bold list item #3[/b]
[/list]

[youtube]http://youtu.be/DabwEqsWWiA&hd=1[/youtube]

[youtube]http://www.youtube.com/watch?v=DabwEqsWWiA[/youtube]


EOF;

$bbcode = new BBCode;
echo $bbcode->toHTML($text);  
?>

Example Output

<strong>This is bold text</strong>

<em>This is italic text</em>

<pre><code>This is pre-formatted text</code><pre>

<blockquote><p>This is a quote</p></blockquote>

Obama wrote: <blockquote><p>This is a quote by a specific person</p></blockquote>

<span style="font-size:30%">This text's size is set at 30%</span>

<del>This text has a strikethrough</del>

<span style="text-decoration:underline;">This text is underlined.</span>

<div style="text-align:center;">This text is centered</div>

<span style="color:red;">This is red text</span>

<a href="mailto:[email protected]">[email protected]</a>

<a href="mailto:[email protected]">An e-mail link</a>

<a href="http://www.google.com/">http://www.google.com/</a>

<a href="http://www.google.com/">Google.com yo!</a>

<img src="http://i.imgur.com/WqYEO.jpg"/>

An image as a link:

<a href="http://en.wikipedia.org/wiki/Ninja"><img src="http://i.imgur.com/8d7Yu.jpg"/></a>

This is an unordered list: 

<ul><li>list item #1</li><li>list item #2</li><li><strong>bold list item #3</strong></li></ul>

This is an ordered (numbered) list: 

<ol><li>list item #1</li><li>list item #2</li><li><strong>bold list item #3</strong></li></ol>

This is an ordered (alpha) list: 

<ol style="list-style-type: lower-alpha"><li>list item #1</li><li>list item #2</li><li><strong>bold list item #3</strong></li></ol>

<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/DabwEqsWWiA" frameborder="0"></iframe>

<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/DabwEqsWWiA" frameborder="0"></iframe>

php-bbcode's People

Contributors

kaimallea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

php-bbcode's Issues

Failed at new line

There is an issue at
e.g. new lines. They will automatically removed.

Composer Support

Hi,

I like your class and will use it for a project.

But it would be awesome to have Composer (and Packagist) support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.