i must obtain the publish content in to the tag <head>. I had been trying with this particular code in to the header.php file of my theme:

$stringa = the_content();

however it does not work.

how do i do? thanks

The functions the_content() and get_the_content() are intended to be used within the WordPress loop, and that means you can't only use them when needed. You will need to develop a loop within your header.php file that queries the WordPress database, brings some content, and uses it as being necessary.

Essentially, wrap your the_content() call inside:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; endif; ?>

Then you will have the ability to fetch publish content anywhere around the page ... however, I do not quite realise why you are looking to get the publish content within the <head> portion of the page. <head> can be used for style terms, <script> tags, and meta details about the page ... not for actual page content. If you are looking to get specific details about the present page, I'd recommend utilizing a different function entirely.

I believe what you're searching for is:

$stringa = get_the_content();
if (is_single()) 
  $content = get_the_content();

You need to put rewind_posts(), otherwise publish loop won't operate in other templates.