calling include from an included file

后端 未结 3 442
攒了一身酷
攒了一身酷 2020-12-14 16:45

So, examining this directory structure

  • /include_one.php
  • /include_two.php
  • /directory/main_file.php

A

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 17:12

    The include path is relative to the first file in the include chain.

    A good way to ensure the correct include path is to always include from the document root.

    This is done like this:

    include $_SERVER['DOCUMENT_ROOT'] . '/folder1/folder2/includetwo.php';

提交回复
热议问题