Icon Patrick Gibsonpatrickgibson.com
news and such projects, etc. movies writings hyperlinks contact
search:
news and stuff

Tuesday, March 11, 2003

SSI to PHP

(Warning: high geek content!) I was recently faced with a problem where I need to convert an HTML file with server side includes (SSI) to PHP, but maintaining the same included files. Enter BBEdit and regular expressions.

PHP, the great language that it is, provides a function called virtual() that performs the exact same task as Apache's built-in SSI. We will replace all of SSI calls to use PHP's virtual() function.

In BBEdit, load up your HTML file (should be renamed to .php), turn on Use Grep, and enter the following lines into the search and replaces boxes, respectively:

<!--#include virtual="([a-zA-Z0-9_/\.-]+)"-->

<?php virtual('\1'); ?>

Click Replace All, and boom! Instant SSI to PHP conversion.

(In case you were wondering, this posting is mostly for me so that I can use it in the future.)

Posted at 09:53
« Too Much | Back to News and Such | Ciao, Cable TV! »

back

Retrix Hosting