I’m used to using includes with large chunks of html outside of the php code, but I’m trying to move to classes or functions because they have increased flexibility and potential for design patterns etc.
I need a function right now that will return a large amount of html, mixed in with some php variables, but I’m looking for away to keep the code outside of the <?php declaration so that it will be formatted like proper html and have code hinting, rather than being a gigantic string.
If it’s possible, how would I go about formatting/writing that?
You can use
include('somefile.html');.include works with vanilla HTML too.
If you need to have it “mixed in with some php variables”, just add those when you need them. Remember: PHP, by its very nature, is a templating language.
For example:
outerHTML.php:
main.php: