How to add some php code in header.php using plugin

Looks like just syntax:

add_action( 'wp_head', function(){ 
    ob_start();
}