note 109758 deleted from function.symlink by cmb

From: Date: Mon, 22 Apr 2019 10:47:26 +0000
Subject: note 109758 deleted from function.symlink by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210656@lists.php.net to get a copy of this message
Note Submitter: kokuswolf at pireality dot de ---- On Linux with PHP 5.4.5 i run into a strange Problem when creating a symlink. My script tests with is_link() and is_file() for a symlink and if its not exists, creating this with symlink. So far no problems. But if i manual delete this symlink and this script runs short after, the script does not found the symlink as aspected. But the script fails when creating the symlink with: "symlink(): File exists" <?php if(is_link($symfile) and is_file($symfile)) echo 'yah!'; else symlink($orginalfile, $symfile); // error :( ?> clearstatcache() does not work, as aspected, because is_link/is_file already works. But I figured out a short workaround with using rename: <?php if(is_link($symfile) and is_file($symfile)) echo 'yah!'; else{ $randfile = 'anywhere_with_rights/random_name'; symlink($orginalfile, $randfile); rename($randfile, $symfile); // voilà ... no error } ?>

« previous php.notes (#210656) next »