PHP virtual paths…
…are a sodding mystery to me! I decided to make my life easier by using PHP included files to write the header, footer and other static stuff on the pages of this site. Was this a good idea? Well, in theory yes. Having the header and footer in separate files means I only have to update them once and the change is reflected across the site. However, for some reason, PHP include files do not let you use a virtual path. Consider this:
<? include("/includes/header.inc"); ?>
This line of code uses a ‘virtual’ path to the folder ‘includes’ containing the file ‘header.inc’. The forward slash stands for the site root. This is useful because we don’t want to be having loads of relative URLs all over the place like:
<? include("../includes/header.inc"); ?>
<? include("../../includes/header.inc"); ?>
etc. With most other web-related stuff you can use the virtual url system, just not with PHP. I’m trying to work out how to do this so I can get rid of the Dreamweaver template system that I’ve been using ever since my host lost all CGI ability (and therefore, Movable Type).
Not being an expert in PHP, I tend to search the web for answers. This time I have drawn a blank. I’m hoping somebody will see this and get in touch. Until I can solve this vexing riddle, you will get some very basic looking pages: mailing list, css emporium to name a few.
**UPDATE** This started annoying me so much so that I’ve completely abandoned the Dreamweaver templates and hand coded the individual relative URLs on each page. I guess at some point I’ll work out how to do what I need to do. For now, as with much to do with this site over the last month, I will cope.