it's because your short tag isn't recognized here:
<? if( count( $news ) == 0 ) {
echo '<p>Sin noticias</p>';
}
//...
Should be:
<?php if( count( $news ) == 0 ) {
echo '<p>Sin noticias</p>';
}
//....
That PHP is not seen as such and therefore not parsed, and the browser sees <?
as a start tag which is ended by the </p>
after "noticias". That's why you get your actual result on the page.
The reason of this is because you likely have short_open_tag directive disabled in your php.ini. Keep in mind that :
Since PHP 5.4.0, <?= is always available
which is the short for <?php echo
, but that doesn't encompass the <?
short tag in lieu of <?php