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.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html"> <meta name="GENERATOR" content="company"> <!--#include virtual="/templates/meta.html" --> <title>Level 1 template</title> <!-- conditionally generated style sheet --> <!--#include virtual="/templates/styles.shtml" --> <!-- conditionally generated javascript code --> <!--#include virtual="/scripts/javascript.shtml" --> </head> <body> <!-- banner/page headings --> <!--#include virtual="/templates/level_1.shtml" --> <div class="page-content"> <!-- unique page contents go here --> </div> <!--#config timefmt="%B %d %Y" --> <!--#set var="real_date" value="$LAST_MODIFIED" --> <!--#include virtual="/templates/footer.shtml" --> </body> </html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="company"> <meta name="keywords" content="blah, blah"> <title>Cool Tools</title> <?php <!-- conditionally generated style sheet --> virtual ("/templates/styles.shtml"); <!-- conditionally generated javascript code --> virtual ("/scripts/javascript.shtml"); ?> </head> <body> <?php <!-- banner/page headings --> virtual ("/templates/level_1.shtml"); ?> <div class="page-content"> <!-- unique page contents go here --> </div> <?php $real_date = date("F d, Y.", getlastmod()); include ("../templates/footer.php"); ?> </body> </html>
Notes:
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.
Tech Stuff
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
Search
Share
Page
Resources
HTML Stuff
W3C HTML 4.01
HTML5 (WHATWG)
HTML4 vs HTML5
HTML5 Reference
W3C Page Validator
W3C DOCTYPE
CSS Stuff
W3C CSS2.1
W3C CSS2.2
Default Styles
CSS3 Selectors
CSS 3 Media Queries
CSS 3 Colors
DOM Stuff
W3C DOM
W3C DOM 3 Core
W3C 3 Events
Accessibility
usability.gov
W3C - WAI
Web Style Guide
WebAim.org
Useful Stuff
Peter-Paul Koch
A List Apart
Eric Meyer on CSS
glish.com
Our Stuff
Our DOM Pages
DOM Navigation
Liquid Layout
CSS Short Cuts
CSS overview
CSS One Page
Javascript Stuff
Site
Copyright © 1994 - 2024 ZyTrax, Inc. All rights reserved. Legal and Privacy |
site by zytrax hosted by javapipe.com |
web-master at zytrax Page modified: January 20 2022. |