Setting PHP Include Path on a per site basis?

后端 未结 7 1269
既然无缘
既然无缘 2020-12-20 11:25

I can set the PHP include path in the php.ini:

include_path = /path/to/site/includes/

But then other websites are affected so

7条回答
  •  一向
    一向 (楼主)
    2020-12-20 12:14

    Why do you think append to include path is bad practice?

    This code near top of root script shouldn't be that bad...

    $path = '/path/to/site/includes/';
    set_include_path($path . PATH_SEPARATOR . get_include_path());
    

    IMHO the main advantage is that it's portable and compatible not only with Apache

    EDIT: I saw a drawback of this method: small performance impact. see http://www.geeksengine.com/article/php-include-path.html

提交回复
热议问题