The comic is quite the learning experience… For example, I’m poking around a bit more with what can be done using PHP. And also what kind of problems crop up with having different versions of Apache and PHP on my laptop and on the server.
Here’s the scenario: I do the comic on my local machine, check to see if everything looks good, then upload it to a remote server.
Problem: The comic is stored in a different place on my local machine from where it is on the server
Old, Sucky Solution: I manually edit the index.php
file to point things to the right directory. This means that if I make a change to the main page, I have to make sure I have the right line commented out before uploading it to the remote server.
New, Shiny Solution: The index.php
variables are assigned different values based on the address of whoever is reading the page.
Here’s the code:
if (getenv('REMOTE_ADDR') == '127.0.0.1') { $comic_path = "/local/path/to/comic/strips"; } else { $comic_path = "/remote/path/to/comic/strips"; }
It’s more intuitive to check on the hostname of the server rather than the address of the reader and assign things based on that, but there’s a problem. The apache_getenv("SERVER_ADDR");
function doesn’t exist in PHP before version 4.3.0, while getenv
has been around since version 3.