根路径不适用于 php include

2022-01-02 00:00:00 path root include php

/在用于访问根文件夹的链接的开头在 php include 中不起作用.

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

例如/example/example.php"

for example "/example/example.php"

解决方案是什么?

推荐答案

我假设根文件夹是指 Web 文档根,而不是文件系统根.

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

为此,您可以

  • 将 web 根文件夹添加到包含路径 和 include('example/example.php')
  • 或者你可以include($_SERVER['DOCUMENT_ROOT'].'/example/example.php')

相关文章