Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
612 views
in Technique[技术] by (71.8m points)

root path doesn't work with php include

/ 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm assuming by root folder you mean your web document root, rather than filesystem root.

To that end, you can either

  • add the web root folder to the include path, and include('example/example.php')
  • or you can include($_SERVER['DOCUMENT_ROOT'].'/example/example.php')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...