为什么PHP函数is_link无法识别链接

问题描述 投票:0回答:1

复制很简单。只需创建一些文件夹,我将其命名为php-test。还有另一个文件夹target。然后cd到php-test

$ mkdir uploads
$ ln -sfn ../target uploads

检查我们是否有符号链接

$ ls -l uploads
total 0
lrwxrwxrwx 1 travel travel 9 Apr 15 18:51 target -> ../target

在当前目录内创建test.php:

<?php

$link = 'uploads';

if (is_link($link)) {
    echo "is link $link\n";
} else {
    echo "not a link $link\n";
}

并运行它

$ php test.php

可能有人解释为什么输出结果是>>

not a link uploads

复制很简单。只需创建一些文件夹,我将其命名为php-test。还有另一个文件夹,目标。然后cd到php-test,$ mkdir上传$ ln -sfn ../target上传检查我们是否有符号链接$ ...

php symlink
1个回答
0
投票

读取the documentation,该参数必须是文件。就像那里所说的:filename是文件的路径。

© www.soinside.com 2019 - 2024. All rights reserved.