开发者

How to compare 2 different string that link to 1 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜