Update: I tried to play with this in a separate script that does nothing but parse, hoping to encapsulate it in a function and call it in my main script.
This works (full script)
PHP Code:
<?php
chdir('forums');
include('global.php');
require_once('includes/class_bbcode.php');
chdir('..');
global $text;
global $parser;
$text = '[b][i]text[/i][/b]';
$parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$text = $parser->parse($text);
echo $text;
?>
So far so good...problem is, this does not:
PHP Code:
<?php
chdir('forums');
include('global.php');
require_once('includes/class_bbcode.php');
chdir('..');
global $text;
global $parser;
$text = '[b][i]text[/i][/b]';
function parseMe() {
$parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$text = $parser->parse($text);
}
parseMe();
echo $text;
?>
I get the same thing as if I try to change the prototype to parseMe($text) and include a return($text) statement, and whether or not I use global variables
The output is:
Code:
Fatal error: Call to a member function query_read_slave() on a non-object in /(elided)/forums/includes/class_bbcode.php on line 220
as usual.
Since it works unencapsulated, I think this has just become a pure PHP question instead of vBulletin-specific, let alone version specific.