is_dir总是以PHP 7返回

时间:2017-02-11 12:52:15

标签: php

我从PHP 7.0.6升级到7.0.13-0ubuntu0.16.04.1,我现在无法使用以下代码行。

protected function prepareOutput($filename, $overwrite)
{
    $directory = dirname($filename);

    if ($this->fileExists($filename)) {
        if (!$this->isFile($filename)) {
            throw new \InvalidArgumentException(sprintf(
                'The output file \'%s\' already exists and it is a %s.',
                $filename, $this->isDir($filename) ? 'directory' : 'link'
            ));
        } elseif (false === $overwrite) {
            throw new Exceptions\FileAlreadyExistsException(sprintf(
                'The output file \'%s\' already exists.',
                $filename
            ));
        } elseif (!$this->unlink($filename)) {
            throw new \RuntimeException(sprintf(
                'Could not delete already existing output file \'%s\'.',
                $filename
            ));
        }
    } elseif (!$this->isDir($directory) && !$this->mkdir($directory)) {
        throw new \RuntimeException(sprintf(
            'The output file\'s directory \'%s\' could not be created.',
            $directory
        ));
    }
}
 **
 * Wrapper for the "is_dir" function
 *
 * @param string $filename
 *
 * @return boolean
 */
protected function isDir($filename)
{
    return is_dir($filename);
}

/**
 * Wrapper for the mkdir function
 *
 * @param string $pathname
 *
 * @return boolean
 */
protected function mkdir($pathname)
{
    return mkdir($pathname, 0777, true);
}
即使文件夹存在,

is_dir也会不断返回false。谁知道我怎么能摆脱这种困境?我已检查文件夹权限并确认www:data有权访问该文件夹。当我删除文件夹时,它会被创建然后错误弹出我们。

0 个答案:

没有答案