Skip to content

Instantly share code, notes, and snippets.

@carliedu
Created May 7, 2021 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carliedu/620595f24b404ec44485c331618935ab to your computer and use it in GitHub Desktop.
Save carliedu/620595f24b404ec44485c331618935ab to your computer and use it in GitHub Desktop.
Get the result of file exist/no exits
<?php
use app\clFilesystem;
use React\MySQL\Factory;
require __DIR__ . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$file = "teste.txt";
echo 'The file ['.$file.'] ['.f_existsFile($filesystem, $file)."]\n";
$loop->stop();
//----- Final do LOOP
$loop->run();
// F U N C T I O N ////////////////////////////////////////////////////
function f_existsFile($filesystem, $file)
{
$filesystem->file($file)->exists()->then(function () {
return 'exists';
}, function () {
return 'was not found';
});
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment