News:

Tekforums.net - The improved home of Tekforums! :D

Main Menu

how to use this

Started by neXus, February 07, 2007, 16:24:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

neXus

I have a huge headache today and probably being thick but how would you use this php class?


class BBParse
{
var $InputString;
var $OutputString;

function BBParse ( $InputString, $OutputString )
{
if ( $This -> Input ==  )
{
return_error ( You have to provide at least a message of 20 characters!, true );
}
else
{
// Define some default BB code tags, such as bold, italic, and url.
$BBCode[0] = /[b]/;
$BBCode[1] = /[/b]/;
$BBCode[2] = /[i]/;
$BBCode[3] = /[/i]/;
$BBCode[4] = /[url]/;
$BBCode[5] = /[/url]/;

// Replacement strings, in HTML ofcourse.
$BBReplace[0] = ;
$BBReplace[1] =
;
$BBReplace[2] = ;
$BBReplace[3] =
;
$BBReplace[4] = ;
$BBReplace[5] =
;

$BBParsedOutput = Preg_Replace ( $BBCode, $BBReplace, $InputString );

}
}
}


external file..
include_once "bbparse_class.php";

Sweenster

in what context do you mean?

madmax

looks like a forum post parser, changes "bb" square tags into html tags

if it was VB, itd be like


dim InputString as string = "some forum [b]post[/b]"
dim outputString as string

BBParse.BBParse(inputstring, outputstring)

debug.print outputstring

"some forum post"


but ive no idea about php

neXus

Yeah, i am using this as a base to create a tag system for code rather then some php stuff, I am just learning some of the php approaches and the function in this code seems to be the best and most memory efficient

I can do object classes, just do not know how this class works when you call it

cornet

Well you would need something like

require_once "bbparse_class.php";

$input = "[b]Hello World[/b] [i]Hello World[/i]";

$bbparse = new BBParse($input, $output);


.... but it wont work cos there are too many bugs in the code. Not to mention this isnt worthy of a class.


neXus

Thought so and full of errors, made a function myself using the php function Preg_Replace()

Can anyone help me a bit though, I know how to have a value of text which if was a submit button etc you can assign and pass through but how do you get such a similar thing to pass through a file?

So you have this function file or class file of code and replacement
You create another file and at the start call the function and when the file is run it reads the function and converts the code and produces its function - basically a template file for example.