We urrently use this technique with PHP5 and Apache 2.x (2.4 currently). We historically used PHP for all our web work. We have decided to migrate to ruby for all our new web development but we still have lots of PHP stuff hanging around that we upgrade and modify as necessary.
We regularly mix PHP and SSIs for the following reasons:
Laziness - we have a lot of historic SSI stuff lying around and do not want to change it. We prefer evolution to revolution.
Appropriateness. Not all systems are good at everything. We find that conditionally selecting 'lumps' of code to deliver browser specific pages (see server side browser sniffing) is a lot cleaner and easier with SSI.
The rules go like this:
You can invoke SSI files from within PHP but must use the PHP virtual() function not include(). Variables set within PHP are NOT available to SSI so our favorite 'wheeze' of supplying last modified dates to a standard footer do not work.
You can include SSI files using the include virtual SSI directive but the SSI filename must have a .shtml extension even if the XBitHack is being used.
You cannot include PHP files using the include virtual SSI directive.
Variables set within the General Apache section (we use this technique for server side browser sniffing) are available to both .php and .shtml files no matter how they are called.
Note: We would guess that the Apache environment for each type of file (.php and .shtml) is initialised to the same state as when the page is first called, whereas a nested .php files uses the same php environment and therefore reflects any dynamic changes.
The following is our standard level 1 template implemented in SSI first and then PHP.
Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.
If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C standards compliant browser such as Firefox