PHP and OOP Templates
While using objects can greatly simplify your code and expedite development of a site, it has a number of limitations, as mentioned in Chapter 2, Object-Oriented Programming. One of the big problems you may encounter is how best to interlace PHP and HTML while promoting separation.
For example, I want every page of the site to use a dynamically created footer such as Last modified Saturday, May 25, 2001. However, the template for the page itself contains only HTML, and if I were to place PHP within it to generate the footer, it would not be executed because the object process merely reads in the HTML template, replaces certain values, and prints it all out to the browser. No PHP execution takes place.
In the index.php object ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access