Edit: This is NOT a general question about undefined variable but about this specific code example that pulls variable without specifying from where.
I'm trying to setup an HTML whitelist of tags as documented here using s9e\TextFormatter.
Here is my code:
use s9e\TextFormatter\Configurator;
function htmlFormat( )
{
$configurator = new Configurator;
$configurator->plugins->load( 'HTMLElements' );
$configurator->HTMLElements->allowElement( 'b' );
$configurator->HTMLElements->allowAttribute( 'b', 'class' );
$configurator->HTMLElements->allowElement( 'i' );
// Get an instance of the parser and the renderer
extract( $configurator->finalize() );
$text = '<b>Bold</b> and <i>italic</i> are allowed, but only <b class="important">bold</b> can use the "class" attribute, not <i class="important">italic</i>.';
$xml = $parser->parse( $text );
$html = $renderer->render( $xml );
}
htmlFormat();
However the variables $parser
and $renderer
are never defined in that sample code. I don't know how to integrate them in this code, do you?