【发布时间】:2018-06-04 21:24:13
【问题描述】:
我在这条路径http://172.16.15.11/appointment/src/上有两个文件test.php和test1.php
我正在检查文件test1.php 是否存在,但是当我提供absolute path 时它不起作用:
我在test.php中有以下代码
//giving absolute path not working
var_dump(file_exists('http://172.16.15.11/appointment/src/test1.php')); //return false
//but when i give relative path it does work
var_dump(file_exists('test1.php')); //return true
为了交叉检查,我在test.php 中尝试了include
include('http://172.16.15.11/appointment/src/test1.php'); //but in this case absolute path work
如果我在我给出绝对路径时它的工作原理
1. include('http://172.16.15.11/appointment/src/test1.php');
2. header('location:http://172.16.15.11/appointment/src/test1.php');
但是当我检查这个文件时不起作用:
var_dump(file_exists('http://172.16.15.11/appointment/src/test1.php')); //return false
注意 - 我没有任何 .htaccess 文件
【问题讨论】:
-
http://172.16.15.11/appointment/src/test1.php不是路径,而是 URL。 -
还有 var_dump(file_exists('appointment/src/test1.php'));不起作用,但 var_dump(file_exists('/var/www/html/appointment/src/test1.php'));作品