I am new to PHP, coming from ASP.net background, the most trouble I am having is generating html from PHP. My question is how is it done in industry? I see 4 ways:
- generate from inside PHP program.
- use PHP “helper classes” to do that.
- mix PHP from inside HTML.
- use templates.
Are there more ways, and which one is used on professional projects. If it number 2 or 4, could you suggest “best” (most used) helper classes, or templates.
Use an MVC framework like CodeIgniter, and follow the standards there. Try to keep your business and display logic as separate as possible!
The reasoning behind this is that if you decide later on to modify your code, it’s easier to find the code in question. It’s simpler to search through a few template files than it is to pick through all your logic to look for one snippet of html.