Relative include files

前端 未结 3 1576
Happy的楠姐
Happy的楠姐 2020-12-03 12:59

I have a file

workers/activity/bulk_action.php which includes a file

include(\'../../classes/aclass.php\');

Inside aclass.php it d

3条回答
  •  生来不讨喜
    2020-12-03 13:55

    You can adapt the second include with:

    include (__DIR__.'/../tcpdf/config/lang/eng.php');
    

    The magic constant __DIR__ refers to the current .php file, and by appending the relative path after that, will lead to the correct location.

    But it only works since PHP5.3 and you would have to use the dirname(__FILE__) construct instead if you need compatibility to older setups.

提交回复
热议问题