Best practices of PHP/HTML web UI application design

Dear PHP Masters,

I am new to the php based web application development. I have little bit of experience in writing perl based cgi applications.

The question is what is the “best practice in coding php applications”.

Most of the php examples include php logic coding and html design tags as interleaved, actually this is creating a lot of confusion in following the php code and consolidating the application logic.

For example take Bugzilla, perl/cgi based coding, has followed a design/coding practice, where templates are separate from the logic . Similarly phpBugTracker also tried to follow the same , but not very accurately.

Please let me know the best practice in PHP & HTML based application.

  1. Should we interleave the PHP code and HTML tags.
  2. Should we keep them separate.

Also please mention the applications following the best practices.

Thanks & Regards,
GL.

Report this post

It depends on your situation.

If your profiling shows that you gain significant performance increases by interleaving, and clarity isn’t significantly decreased, then stay with interleaving.

If keeping them separate makes it much easier to manage your code, and performance isn’t significantly impacted, then that’s the way to go.

These Advanced PHP Resources can be of help too.

But in the end, it depends.