I have files with fragments of boilerplate HTML that will be read and output by PHP. I'd rather not use ".html" extension for these files because I'd like to reserve ".html" to indicate a complete HTML page.
Is there an established filename extension for HTML fragments?
If you are include()-ing it into PHP scripts, you can give it any extension, as PHP won't care. I typically give it a .php suffix so that I can throw a line or two of code at the top to keep it from being called directly via HTTP (if that is a concern).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
1234 5th St.<br />
Los Angeles, CA 91234<br />
ph. (310) 555-1234<br />
fax (310) 555-6789<br />
So I'm using extension .htxt to indicate text with html markup, but not a complete well-formed html page. I wondered if there was already an extension established for this purpose.
readfile(), include(), require(), file_get_contents(): it doesn't matter. PHP won't care what the suffix is, so use whatever you like -- including my suggestion for ".php" if you want to prevent direct access via browsers.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks