/    Sign up×
Community /Pin to ProfileBookmark

mix and match?

I’ve noticed that some people mix and match php and html. and some write entirely in php and echo/print the html elements.

are there benefits to either method? which is the prefered (industry standard) method.

Thanks guys

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@PineSolPirateJul 14.2006 — I've done it both ways, but I prefer to mix and match. Otherwise you might as well user perl or python or something. I think the mix and match is one of the best strengths of php.
Copy linkTweet thisAlerts:
@aaronbdavisJul 14.2006 — mix and match is fine for small scripts. Most of my site is written that way. However, when you have a larger site, or at least larger scripts, most people will separate the presentation (i.e. HTML) from business logic (i.e. PHP) using some sort of template engine like [URL=http://smarty.php.net]Smarty[/URL]. In the long run, it make scripts much easier to maintain. People have also been talking alot about MVC frameworks which, from what I have read, make things much easier than a simple template engine.
Copy linkTweet thisAlerts:
@PineSolPirateJul 14.2006 — Amen to smarty. Thats the coolest thing ever for letting coders and design people work together. I'm actually re-coding my site in it right now. As far as MVC frameworks, do you know any good ones? I was looking at some based on model2 but everything seems so poorly documented.
Copy linkTweet thisAlerts:
@NogDogJul 14.2006 — I'm flexible to some degree, but I don't like having to read code that goes back and forth repeatedly. Sometimes I end up using echo with heredoc syntax to output a chunk of plain HTML rather than jumping out of PHP mode. Maybe it's because most of my first experiences with web programming were in Perl?

Now that I'm trying to do more with object-oriented PHP, I find myself putting chunks of HTML into methods, so that the overall program logic isn't interrupted by chunks of HTML, but instead by method calls such as [b]$this->printDocHead();[/b] or [b]$this->printNavigation();[/b].
Copy linkTweet thisAlerts:
@PineSolPirateJul 15.2006 — Before I started using smarty I usually had a header and footer include, which helped clean things up. Nav includes are handy too.
×

Success!

Help @Sid3335 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...