There are several examples on the net, however I use this:
<?php
//functions.php
add_filter( 'widget_text', 'php_parser', 100 );
function php_parser( $html ){
if( strpos( $html, "<"."?php" ) !== false ){
ob_start();
eval( "?".">".$html );
$html = ob_get_contents();
ob_end_clean();
}
return $html;
}
?>