Separating HTML from PHP
The last approach I want to discuss involves using the include and require functions. As you may recall from Chapter 8, "I/O Functions," these functions include a file in the PHP code. The file is considered to be a PHP file, regardless of the extension on the name. If PHP code appears in the included file, it is surrounded in <? and ?> tags. You may want to turn back to the functional reference to refresh yourself on the differences between include and require, but they aren't particularly important to this discussion.
Certain chunks of HTML must appear on every well-formed page. Additionally you may develop repeating elements such as a company logo. Rather than write them into every page, you may choose to put them ...
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