Change the purpose of a symbolic link to PHP

How can I change the purpose of a symlink in PHP? Thanks.

+4
source share
2 answers

You can delete the existing link using unlink and recreate the link to the new target using symlink .

symlink($target, $link); . . unlink($link); symlink($new_target, $link); 

You need to perform error checking for each of them.

+8
source

PHP can execute shell commands using shell_exec or backtick operator .

Consequently:

 <?php `rm thelink`; `ln -s /path/to/new/place ./thelink`; 

This will be executed as the user who starts the Apache server, so you may need to keep this in mind.

0
source

Source: https://habr.com/ru/post/1304837/


All Articles