Search code examples
phpssi

Is there ever a situation where server-side includes are a better choice than PHP?


I'm asking in regards to otherwise-static webpages which include files like headers, footers, etc. Obviously building a dynamic site with SSI would be better done with PHP.

Is there ever any reason to do

<!--#include virtual="../quote.txt" -->

instead of

<?php include("../quote.txt"); ?>

(or the equivalent in another language)?

I'm asking because I've been given the task of updating a website which is currently using SSI for including the same header on different pages.


Solution

  • If you're not using any other PHP in the page, using an SSI means your Apache processes don't need to load up the PHP interpreter to generate and serve the HTML.