jasmine
jasmine

Reputation:

write php codes independent from template

How can I write php codes independent from XHTML codes?

Upvotes: 1

Views: 161

Answers (3)

Benoit
Benoit

Reputation: 3588

Or you can separate logic from markup only with pure php, which is in fact a good templating language.

Before doing MVC, an approach was to put code on separate classes, getting results needed on top of page and only using variables to echo or loop them inside html markup. You can use the same pattern to included portions of xhtml, the separations of concerns is then moved to pure code files and classes design.

But as we are 2010 I definitely vote for using MVC, even for very small project, with or without a framework.

Upvotes: -1

ahmetunal
ahmetunal

Reputation: 3950

You can study MVC structure.

Also have a look at smarty.

Upvotes: 1

Gaurav Sharma
Gaurav Sharma

Reputation: 2848

Use a PHP framework like cakePHP or Zend.
or create a custom solution and use template engine like Smarty for separating your code logic with design.

Upvotes: 1

Related Questions