João Cândido de Souza Neto wrote:
> You made a mistake in your code:
> 
> <?php the_title(); ?>
> 
> must be:
> 
> <?php echo the_title(); ?>
> 

Not necessarily: what if you have

function the_title()
{
        echo "Title";
}

for example...


In response to Sebastiano:

There would be not much point in using something like PHP if it ignored the "if"
statements in the code!
What effectively happens in a PHP source file is that all the bits outside of
the <?php ?> tags are treated like an "echo" statement (except that it handles
quotes and stuff nicely)

Your original code:

<?php if (the_title('','',FALSE) != 'Home') { ?>
<h2 class="entry-header"><?php the_title(); ?></h2>
<?php } ?>

can be read like:

<?php
if (the_title('','',FALSE) != 'Home') {
    echo '<h2 class="entry-header">';
    the_title();
    echo '</h2>';
}
?>

You might even find a small (but probably really, really, really small)
performance improvement if you wrote it that way, especially if it was in some
kind of loop.
Note that I prefer to keep HTML separate from PHP as much as possible because it
helps me to read it and helps my editor check my syntax and HTML structure 
better...


-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to