i would like to improve my coding quality when i use PHP code and for that i
would request your help.
in my web developer experience, i have to confess that i've never succeeded
in spliting PHP code from HTML code.

There's a myth that by separating html and php your code is cleaner, it's a little more than that. What you should consider doing is separating the "business logic" from the "display logic".

The business logic includes things like database calls, data calculations, etc.

Display logic is what the page actually looks like. This will likely include both HTML and PHP, but the PHP will be limited to echoing out variables, as you should have already done all calculations.

One very good way to do this separation is by using the MVC pattern - http://en.wikipedia.org/wiki/Model-view-controller . I've found that using the MVC pattern helps me to write cleaner, more maintainable code as you always know where the code for a given function is located. Need to edit what the page looks like? It's in the view. Need to edit your database calls? It's in the model. Anything else? It's in the controller.

There are lots of great frameworks out there that use the MVC pattern. Personally I use and recommend CodeIgniter (http:// www.codeigniter.com) - it's been a great one for me, but there are plenty of other well written frameworks out there if CodeIgniter isn't a good fit for you.

HTH,

Brady

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to