Excessive PHP Tags

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joby65
Forum Newbie
Posts: 1
Joined: Fri Dec 19, 2008 9:54 am

Excessive PHP Tags

Post by joby65 »

Is it more efficient to use a single open and close tag (<?php ?>) and output html using echo, or should many php tags be used so that html is outputted normally?.

Example:

1. <?php
if(condition)
{
echo 'some html';
}
?>

2. <?php

if(condition)
{
?>
some html

<?php

}

continue ph script

?>
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Excessive PHP Tags

Post by Eran »

No, the opposite is true. The parser will ignore anything not inside a php tag, so it actually has (slightly) less work to do. I also find HTML to be more readable when it's outputted normally.
Post Reply