/    Sign up×
Community /Pin to ProfileBookmark

To echo html tags or not.

Got a quick preference question.

I have a lot of php code, and in my code I sometimes echo html tags. For example:

echo “<h1>booyah!</h1>”;

Now another way I do this is just ending my php code with a ?> and start it back up again later after my html. For example:

//some php code
?>
<h1>booyah</h1>
<?

Now I’m fairly inconsistent with this, is that a problem? Is there one method that just preforms better than the other or does it not really matter? Thanks!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Jeff_MottOct 30.2007 — The difference there hardly matters at all. But if you're building a large Web application, or even a moderate-sized application that you want to keep scalable, then you should keep *ALL* HTML out of your PHP code and use a template system instead. It's one of those good engineering practices, to keep parts modular and independent of each other.
Copy linkTweet thisAlerts:
@Stephen_PhilbinOct 31.2007 — I would drop out of PHP parsing and output the tags as normal, but like Jeff said, there's not a great deal of difference anyway. The important thing is to be consistent.
×

Success!

Help @bejitto101 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...