How can PHP scripts be modified to ensure that the owner/group of copied files is the same as when copied manually?

When copying files using PHP scripts, the owner/group of the copied files may not be the same as when copied manually due to permission settings. To ensure that the owner/group remains the same, you can use the `chown()` and `chgrp()` functions in PHP to change the ownership and group of the copied files after the copy operation.

// Copy file
$source = '/path/to/source/file.txt';
$destination = '/path/to/destination/file.txt';
copy($source, $destination);

// Set owner/group of copied file
$owner = fileowner($source);
$group = filegroup($source);
chown($destination, $owner);
chgrp($destination, $group);