templates will be faster to load(less work for the system) and safer, also a lot less complexity as you wont have to deal with the issues you are currently trying to solve.
what you what to do is quite literally the purpose of templating systems.
diving deeper into what you are doing....
you should never put sql credentials IN a file that is in a public directory. If PHP is broken for some reason in the future it would allow anyone viewing that page to see the database credentials. Always store credentials and other important stuff outside of the public directory and use an include to access it inside code that lives in public directory.
|