What are the best practices for handling smileys and BB code when extracting and displaying PHPBB forum content in a different context?

When extracting and displaying PHPBB forum content in a different context, it's important to properly handle smileys and BB code to ensure that the content is displayed correctly. One way to do this is by using PHPBB's built-in functions to parse and convert smileys and BB code before displaying the content.

// Assume $forumContent contains the raw forum content

// Parse smileys
$forumContent = $phpbb_root_path . 'includes/functions_content.' . $phpEx;
include($forumContent);
$forumContent = smiley_text($forumContent);

// Parse BB code
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$forumContent = $bbcode->parse_message($forumContent);

// Display the processed content
echo $forumContent;