How can PHP be used to copy a file to another location if certain conditions are met, such as file age?

To copy a file to another location in PHP based on certain conditions like file age, you can use the `filemtime()` function to get the last modified time of the file and compare it with the current time minus the desired age threshold. If the file meets the condition, you can use the `copy()` function to copy the file to the new location.

$sourceFile = 'path/to/source/file.txt';
$destinationFolder = 'path/to/destination/';
$ageThreshold = 86400; // 24 hours in seconds

if (file_exists($sourceFile)) {
    $fileAge = time() - filemtime($sourceFile);

    if ($fileAge >= $ageThreshold) {
        copy($sourceFile, $destinationFolder . basename($sourceFile));
        echo 'File copied successfully.';
    } else {
        echo 'File does not meet age condition.';
    }
} else {
    echo 'Source file does not exist.';
}