Re: Re: newbie question - php parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, it's now much more clear. I thought that html parts outside
php tags were just dumped to output, no matter of if-else statements
and other conditions. I was *definitely* wrong

2009/7/23 Peter Ford <pete@xxxxxxxxxxxxx>:

> 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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux