note 87289 added to function.copy

From: Date: Fri, 28 Nov 2008 11:15:41 +0000
Subject: note 87289 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-147061@lists.php.net to get a copy of this message
As far as recursive copy, something like this seems to work fine for me: <?php $output = shell_exec( " cp -r -a dir_source/* dir_dest 2>&1 " ) echo $output ?> Of course you need to get all your permissions clear. You can do the necessary stuff to use variables. You could also do this to create the destination directory: <?php shell_exec( " cp -r -a dir_source dir_dest 2>&1 " ) ?> This will create a new directory called "dir_dest" if it does not already exist. This is a bit risky though if your situation is ambiguous, and you want to continue to make backups etc, 'cause if you do it twice you end up with: dir_destination/dir_source to avoid that one could do something like: <?php shell_exec( " mkdir dir_dest; cp -r -a dir_source/* dir_dest 2>&1 " ) ?> Maybe someone can tell me when or why it would be better to use all that PHP code I see here. ---- Server IP: 64.71.164.2 Probable Submitter: 65.167.126.114 ---- Manual Page -- http://www.php.net/manual/en/function.copy.php Edit -- https://master.php.net/note/edit/87289 Del: integrated -- https://master.php.net/note/delete/87289/integrated Del: useless -- https://master.php.net/note/delete/87289/useless Del: bad code -- https://master.php.net/note/delete/87289/bad+code Del: spam -- https://master.php.net/note/delete/87289/spam Del: non-english -- https://master.php.net/note/delete/87289/non-english Del: in docs -- https://master.php.net/note/delete/87289/in+docs Del: other reasons-- https://master.php.net/note/delete/87289 Reject -- https://master.php.net/note/reject/87289 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147061) next »