PHP Dynamic include based on current file path

前端 未结 4 2053
北海茫月
北海茫月 2021-02-04 09:59

I want to find a method to include some files based on the current file path.. for example:

I have \"website.com/templates/name1/index.php\", this \"index.php should be

4条回答
  •  误落风尘
    2021-02-04 10:14

    I'd just do something as simple as:

    $dir = str_replace('website.com/','website.com/content/',__DIR__);
    include "$dir/content.php";
    

    And your HTTP wrapper issue doesn't seem to have anything to do with this. What do you mean by overrun it? You generally never want to do a remote include.

提交回复
热议问题