root path doesn't work with php include

后端 未结 8 1590
天命终不由人
天命终不由人 2020-12-03 00:56

/ in the beginning of a link to get to the root folder doesn\'t work in php include.

for example \"/example/example.php\"

What is the solution?

8条回答
  •  佛祖请我去吃肉
    2020-12-03 01:06

    include() (and many other functions like require(), fopen(), etc) all work off the local filesystem, not the web root.

    So, when you do something like this

    include( "/example/example.php" );
    

    You're trying to include from the root of your *nix machine.

    And while there are a multitude of ways to approach what you're doing, Paul Dixon's suggestions are probably your best bets.

提交回复
热议问题