PHP include absolute path

后端 未结 3 2036
遇见更好的自我
遇见更好的自我 2020-12-01 14:11

I have a variable on my site called $basePath which is set as:

$basePath = \'/Systems/dgw/\';

I am using it on all my css, js and images ta

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 14:49

    You can add an include_path = ".:/home/myuser/mysite.com/" to your php.ini or you can add something like this into your script before the include or require:

    set_include_path(get_include_path() . ":/home/myuser/mysite.com/");
    

    The first one will work for all the scripts running in your website.

    The second option will only work for the script which has the setincludepath on the code, for the rest of the application it will not work unless you have an object you call in every script that add the setincludepath.

提交回复
热议问题