开发者

How to compare 2 different string that link to 1 directory?

开发者 https://www.devze.com 2023-02-08 22:39 出处:网络
For example, next 2 vars give a link to same directory, but strings are different. How can I detect they means same directory?

For example, next 2 vars give a link to same directory, but strings are different.

How can I detect they means same directory?

$开发者_高级运维dir1 = 'application/somedir/some_subdir/../';
$dir2 = 'application/somedir/';


Use realpath()

if (realpath($dir1) == realpath($dir2)) {
    do_stuff();
}

See http://php.net/manual/en/function.realpath.php

You may also want to check that the directories exists before use it.

0

精彩评论

暂无评论...
验证码 换一张
取 消