views:

45

answers:

2

I have a particular php class that I want to be able to upload identical copies to two different servers. Depending on the server though, the requires will be located in different places. (the constants and globals are slightly different as well) Can I conditionally set require_once, Globals, or constants at the beginning of the file?

+4  A: 

You can. If that's the way you want to tackle the problem, you just need to decide how you're going to determine which server the code is being run on. You could try using the domain name:

if ($_SERVER['SERVER_NAME'] == 'mydomain1.com') {


} else {
    // default

}
webbiedave
+3  A: 

Of course:

<?php

if (/* some conditions */) {
    require_once('some.file.php');
} else {
    require_once('another.file.php');
}

?>
Michał Mech