[FX.php List] Embed php into HTML or vice versa?

Steve Hannah shannah at sfu.ca
Thu Aug 31 14:36:20 MDT 2006


Hi Jonathan,

There is a design pattern called Model-View-Controller (MVC) that,  
when followed, seems to yield optimal results.  The idea is that you  
handle the model (which would be the database access), the view  
(which would be your templates and HTML pages), and the controller  
(which would be your program logic in PHP) separately.

Smarty (http://smarty.php.net) can really help you to achieve the  
results.

If you don't want to get into smarty, a good way to start is to do  
all of your logic in a separate PHP file or functions, and store all  
of the information that needs to be displayed on the page in  
variables - so that when it comes time to display the HTML, you are  
only embedding simple PHP variables and very little logic.

I really do recommend getting into Smarty, though.  If you try MVC  
with only PHP you will likely still get frustrated when including  
loops and if statements in the HTML.

Best regards

Steve
----------------------------------------
Steve Hannah
Web Services Developer

Faculty of Applied Sciences
Simon Fraser University
shannah at sfu.ca
604-268-7228
Homepage: http://www.sjhannah.com
--
Need to build a database driven web application quickly?
Try Dataface: http://fas.sfu.ca/dataface



On 31-Aug-06, at 1:16 PM, Jonathan Schwartz wrote:

> I'd like to get better at coding my scripts.
>
> One thing that I have not developed a sense for yet: when it is  
> best to embed php tags into html versus embedding html into php code.
>
> I tend to waste the most amount of time solving parse errors when  
> embedded html into php, it seems, especially in dealing with quotes  
> and such.
>
> I hope that this question makes sense.
>
> Thanks
>
> Jonathan
>
>
> -- 
>
> Jonathan Schwartz
> FileMaker 8 Certified  Developer
> Associate Member, FileMaker Solutions Alliance
> Schwartz & Company
> jonathan at eschwartz.com
> http://www.eschwartz.com
> http://www.exit445.com
> 415-381-1852
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>



More information about the FX.php_List mailing list