[PHP] General question about if


<?php 

if( copy($source, $dest) )
{
	$msg = "Copied $source to $dest";
}

?> 

echo($msg);


If you have this code, $source will be copied to $dest, because if the command works, then it will return “true.” But how would you test if the file could be copied or not without actually executing the command? This would be useful if you have a user wanting to copy a file to another folder. It would check if it could be done. Then give the user a “are you sure?” prompt.