我需要用来file_get_contents()获取文件(file.php)中html页面(content.html)的内容,该文件位于如下目录中:
/content
- content.html
/functions
- file.php
Run Code Online (Sandbox Code Playgroud)
所以我尝试使用file_get_contents('../content/content.html')来获取 html 内容,但出现此错误:
failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我想我可能使用了错误的路径。我能做些什么?
始终使用$_SERVER['DOCUMENT_ROOT'] ,这样您就不必处理文件路径的问题。
尝试:
file_get_contents($_SERVER['DOCUMENT_ROOT'] .'/content/content.html');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2888 次 |
| 最近记录: |