deeped
deeped

Reputation: 21

Php: include files localhost and server: different paths

let's imagine this situation: your developer directory is something like this:

the "common items" are common files, classes, functions which are to be used commonly in your project. So in project "X":

require_once '../commonitems/mysqlDate.php';

and so on. Common items cant be copied multiple times to each projects. But when you need to upload all of this to directory, it cant be like that. A remote website structure is:

so no outside "common items" directory. How to say "elegant" way to include files different on localhost and remote site? Should I set up "if SERVERNAME == localhost then include X else include Y" looks silly :P

thanx in advance

Upvotes: 2

Views: 1356

Answers (1)

Sjoerd
Sjoerd

Reputation: 75629

Use

require_once 'commonitems/mysqlDate.php';

and set the PHP include_path to the correct directory on your development environment.

Upvotes: 2

Related Questions