III. Using NBBC

[ Previous: A. Your First NBBC Program | Next: C. Adding Your Own Tags ]

B. How a Typical NBBC Program Works

While the example in the previous section is simple, it's not very useful. Generally, most programs using NBBC will be structured like this:

Code:
<?php ...other includes... require_once("nbbc.php"); ... $bbcode = new BBCode; ...possible additional optional setup for the $bbcode object... ... $string = [some BBCode from somewhere, usually either a file or a database] $output = $bbcode->Parse($string); ... print $output; ?>

The setup phase, where you create the new BBCode object and maybe alter its functionality a little (say, to add more smileys and BBCode rules, or remove existing ones), only needs to be done once in your script: The BBCode object, once it's been set up, can be reused again and again to convert different pieces of BBCode text in the same script.

[ Previous: A. Your First NBBC Program | Next: C. Adding Your Own Tags ]


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