III. Using NBBC

[ Previous: II.B. Installation | Next: B. How a Typical NBBC Program Works ]

A. Your First NBBC Program

NBBC is designed to be very easy to use, even for the most meager of PHP programmers. Let's try creating your first program that parses BBCode. Create a new file in your project directory, named "hello.php", and use your favorite text editor to put this very simple PHP program in it:

Code:
<?php require_once("nbbc.php"); $bbcode = new BBCode; print $bbcode->Parse("[i]Hello, World![/i] This is the magic of [b]BBCode[/b]!"); ?>
Output:
Hello, World! This is the magic of BBCode!

Let's look at what this does. First, the require_once directive adds NBBC to your program. Next, new BBCode creates a new BBCode parser object and sets it up to be ready for performing parsing. The new BBCode object is then stored in the variable $bbcode. Finally, the big one... we ask the BBCode object to convert some BBCode text to HTML, and we print the result.

[ Previous: II.B. Installation | Next: B. How a Typical NBBC Program Works ]


Copyright © 2010, the Phantom Inker. All rights reserved.