I usually have a config-file with some global variables for database connectivity settings (such as db host, db name, user, pass).
I also really like to be able to just drag and drop all files from my dev machine to the production server. However, development db host etc may be different from the one on the production server.
Is there an easy way of, in PHP, saying something like “if I’m on the dev-machine, use these values”? (I’d prefer to avoid hacks based on host IP / name.) I’m thinking of something like perhaps setting something in php.ini or httpd.conf so that for instance $DEV_MACHINE, is set to true on the dev machine.
You can set up an Apache variable with
SetEnv, and query it with PHP’sapache_getenv().