Principles and Problems

If you have worked for any length of time with PHP, you are bound to have encountered the problem of structuring larger projects. Because embedding PHP in HTML code is easy, the temptation is often to mix the logic of your application with its presentation.

This soon causes a number of problems, however. You tend to find that you are copying and pasting code between files, as the views in your project increase. When you add to your code, you suddenly find that you must repeat your amendments across many pages. Some parts of your project might rapidly fall out of synchronization with others, especially if you are working as part of a team.

Another problem of binding your logic and presentation is the difficulty for designers. ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.