Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active April 20, 2024 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsee/647393a744f23bb2594cd309ba92e56c to your computer and use it in GitHub Desktop.
Save mcsee/647393a744f23bb2594cd309ba92e56c to your computer and use it in GitHub Desktop.
<?
$sourceFile = 'C:\temp\source.txt';
$destination = 'C:\temp\destination.txt';
$copyWasSuccessful = copy($sourceFile, $destination); // true
$destinationFileExists = file_exists($destination); // true
$sourceFile = 'C:\temp\source.txt';
$destination = 'C:\temp\destination :txt';
// The filename is simplified
// and might come from a programmatic construction
$copyWasSuccessful = copy($sourceFile, $destination);
// true - this is a mistake
$destinationFileExists = file_exists($destination);
// false since it was not created
$destinationChangedFileExists = file_exists('C:\temp\destination ');
// true but unexpected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment