I administer several PHP driven sites where I have a template file that includes another file with most of the main content. I pass a variable called $page to determine which main content file to include. Some of the individual content files have just plain HTML and some have HTML and PHP. Each one of these files is called "main_whatever.php" (ie. main_products.php, main_download.php, etc...). All of them have the PHP extension, even the ones with only HTML code. I realize that files without PHP code should be not be named .php so they won't be parsed by the PHP engine. I'm trying to figure out what would be faster. To name all the files .php and suffer a slight hit to parse files that don't have any PHP code...or to run some code like this:
if (file_exists ("main$page.php")) {$include = "main$page.php";}
else {$include = "main_$page.html";}
include ($include);
This would of course incur the overhead of checking the file system for files named main_whatever.php or main_whatever.html.
Which would yeild better performance? Any thoughts?