count newlines in heredoc variable



How could I count the number of newlines in a heredoc variable? This
outputs 0, but I thought heredoc preserved newlines?

<?
$test = <<<END
<a href="test5.php">adam</a>
<p>
Hi There
</p>
END;

echo substr_count($test, '\n');
?>
.