PhP touch on non existing file returns true
i have a function wich makes a check if a folder is writable. but when i try to use the php touch variable in it like this
public function isFileServerMounted()
{
$config = $this->getServiceLocator()->get('config');
$storageDir = $config['xxx']['xxx']['xxx'];
$mountCheckFile = $config['xxx']['xxx']['xxxx'];
// we are using a simple file check as indication if we are mounted
return touch($storageDir . DIRECTORY_SEPARATOR . $mountCheckFile);
}
The function always returns true, regardles if the file i am checking is there or not. i checked the paths and they are correct and i can acess the file via nano over schiell.
The touch comand always returns true, regardles if i delete or make the mount check file.
Anyone has any idea why?
I am using:
PHP 5.3.3-7+squeeze19 with Suhosin-Patch (cli) (built: Feb 17 2014 10:10:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
OS:
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.3 (squeeze)
Release: 6.0.3
Codename: squeeze
touch() is to sets access and modification time of file.
If the file does not exist, it will be created.
Maybe you can use file_exists like this:
$filename = $storageDir . DIRECTORY_SEPARATOR . $mountCheckFile;
if (!file_exists($filename))
return false;
return touch($filename);
链接地址: http://www.djcxy.com/p/65086.html
上一篇: 错误在安装了CentOS 6.7的Sentora面板1.0.3上运行Joomla 3.4.5
下一篇: PhP触及不存在的文件返回true