how do i separate html codes from logic using php classes.
PHP OOP problem
As in what?
Standard PHP classes are seperated like so:
This will appear as:
Welcome
Here, you get to vote for the face of 2006.
John Smith is option one
Please email your choice to: vote@youcanvoteonthissite.com
Standard PHP classes are seperated like so:
| Code: |
|
<HTML> <HEAD> <title>Who's the face of 2006? Vote now.</title> </HEAD> <BODY> <h1>Welcome</h1> <h3>Here, you get to vote for the face of 2006.</h3> <?php echo '<br>John Smith is option one'; ?> Please email your choice to: vote@youcanvoteonthissite.com </BODY> </HTML> |
This will appear as:
Welcome
Here, you get to vote for the face of 2006.
John Smith is option one
Please email your choice to: vote@youcanvoteonthissite.com
Thats not a class and definitely isn't seperating logic from output.
kawkazEE, I believe you are looking for a templating engine. There are many around, some basic and some more complex. The basic ones will just replace vars in templates with vars defined in your code. The more complex ones will do if statements, parse php and loop etc.
Basic ones can be premade scrips or even better created by yourself following a tutorial such as this one. This gives you an understanding of what is going on, specially useful if rather new to the whole thing.
http://codewalkers.com/tutorials/58/1.html
For a more complex one, I can't suggest enough, ETS, which is in my opinion, one of (if not the) best template engines around. (specially as its free and open source!)
kawkazEE, I believe you are looking for a templating engine. There are many around, some basic and some more complex. The basic ones will just replace vars in templates with vars defined in your code. The more complex ones will do if statements, parse php and loop etc.
Basic ones can be premade scrips or even better created by yourself following a tutorial such as this one. This gives you an understanding of what is going on, specially useful if rather new to the whole thing.
http://codewalkers.com/tutorials/58/1.html
For a more complex one, I can't suggest enough, ETS, which is in my opinion, one of (if not the) best template engines around. (specially as its free and open source!)
hi, kawkazEE, or you can have a try smarty. Which is also a template engine build from php.net
Take a look of it to see if it suite you needs.
http://smarty.php.net/
Take a look of it to see if it suite you needs.
http://smarty.php.net/
tnx for the help guys.... i think i can make from here... tnx!!!

