FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP OOP problem





kawkazEE
how do i separate html codes from logic using php classes.
X3 Talk
As in what?
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
mathiaus
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!)
blueray
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/
kawkazEE
tnx for the help guys.... i think i can make from here... tnx!!! Wink Wink
Related topics
PHP OOP
PHP OOP Tutorial
PHP script problem
Stats problem - php execution problem (MOD Assist Required)
php msql problem
php mail(); problem... half fixed?
PHP noob problem
PHP Includes Problem
Php, mime_content_type() problem
php security problem
PHP Login Problem
What is useful way in this php+mysql problem?
problems for indexing php pages in google.
[PHP] classes problem..
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.