简体   繁体   中英

PHP touch() function always returns false

The following code:

if (!touch($this->cacheDirectory . '/index.html')) {
$this->error("Could not create the index.html file in the cache directory.");
}

always returns the user error in Mac server means the above touch function returns false.

Things that I have verified:

  • Creation of file via terminal (unix console) works fine - using touch command.
  • The cacheDirectory folder has permission 775.
  • The group of this folder is _www and the apache user in Mac is _www .

Please help.

Look here:

http://www.php.net/manual/de/function.touch.php#86781

Actually, Glen is right, PHP won't touch if it is not the current owner of the file, even if the directory and files are writeable by the PHP user.

So, remove the file and let PHP create it with touch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM