User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 425,936 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 734 | Replies: 1
Reply
Join Date: Jan 2006
Posts: 11
Reputation: jaikar is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jaikar jaikar is offline Offline
Newbie Poster

Help $verbose... No idea yet, :-(

  #1  
Feb 11th, 2007
Hi,
The code below is to copy the files from one dir to another. here in the function dircopy $verbose is set to false. and later a action is done when the $verbose is true. in between there are no actions that are setting the $verbose to true... when do this $verbose is changing to true ?... any idea ?? Please advise.....

[PHP]function dircopy($srcdir, $dstdir, $verbose = false) {
$num = 0;
if(!is_dir($dstdir)) mkdir($dstdir);
if($curdir = opendir($srcdir)) {
while($file = readdir($curdir)) {
if($file != '.' && $file != '..') {
$srcfile = $srcdir . '\\' . $file;
$dstfile = $dstdir . '\\' . $file;
if(is_file($srcfile)) {
if(is_file($dstfile)) $ow = filemtime($srcfile) - filemtime($dstfile); else $ow = 1;
if($ow > 0) {
if($verbose) echo "Copying '$srcfile' to '$dstfile'...";
if(copy($srcfile, $dstfile)) {
touch($dstfile, filemtime($srcfile)); $num++;
if($verbose) echo "OK\n";
}
else echo "Error: File '$srcfile' could not be copied!\n";
}
}
else if(is_dir($srcfile)) {
$num += dircopy($srcfile, $dstfile, $verbose);
}
}
}
closedir($curdir);
}
return $num;
}[/PHP]

~J
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 37
Reputation: jblacdao is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
jblacdao jblacdao is offline Offline
Light Poster

Re: $verbose... No idea yet, :-(

  #2  
Feb 15th, 2007
Actually $verbose is just used as a flag once you call the function. Its set to false by default, meaning while copying the files it won't printout anything as files are being copied. However, if you supply a true value once you called this function like

 dircopy($src, $dest, true); 

as files are copied, you will receive a printout everytime a file is successfully copied
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:19 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC