$filepath = $path . DIRECTORY_SEPARATOR . $file;
Although in newer versions of PHP it doesn't matter which way the slashes go, so it is fine to always use forward slashes.
You can get a correct absolute path using realpath()
, this will also remove things like extra unnecessary slashes and resolve references like ../
. It will return false if the path is not valid.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…