Highlighter PHP class - v1.0

Waht the class does - Main features

Functions in the class

highlight

function highlight($text)

@param string $text the code to highlight
@return string the code, highlighted

Highlights the code and links functions to their page on php.net

add_tags

function add_tags($text, $ype = "code", $div = 0)

@param string $text the code to parse
@param string $type the code tag to add
@param bool $div switch beetwen divs and "pure-tags"
@return string the new text, tagged!

Actually executes the query and return the result

check_be_tags

function check_be_tags($code)

@param string $code the code
@return bool returns TRUE if tags are present, else FALSE

Checks if the begin and end tags are present in the code block

add_be_tags

function add_be_tags($code)

@param string $code the code
@return string the code with tags

Adds the begin and end tags to a code block

Examples of use

Example #1

The following code will add the "box" tag to the text and highligh it using php's default colors. Then it will link all the functions to their page on the php manual

include_once('highligher.php');

$highlight = new Highlighter;
$code = $highlight->add_tags($code, "box");
$code = $highlight->highlight($code);

echo $code;

Example #2

If the code passed to the method was

$code = "Hello World!";
add_tags($code, "boxed", 1);


The returned code would be (in HTML)

Hello World!

Example #3

If the code passed to the method was

$code = "Hello World!";
add_tags($code, "boxed-class", 0);


The returning text would be (in HTML)

Hello World!

Changelog

No changes made since now.

License

Copyright (C)2007 Giulio Bai

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

A copy of the full license can be found in the official GNU's site

Notes

Links

Plase share it!

If you found this program useful, share it! Maybe it can help also other people!
Don't be scared, it's free, editable, redistributable.
So... share, Share, SHARE!

Contacts

If you want to know more about this program, you can contact me at slide.wow@gmail.com.
Wht do you think about this program? Is it useful? How can be improved?