开发者

Php: include files localhost and server: different paths

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

  • project A
  • project B
  • project C
  • common items

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:

  • css
  • js
  • design
  • common
  • code
    • code/common

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

开发者_JAVA技巧thanx in advance


Use

require_once 'commonitems/mysqlDate.php';

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜