Skip to content

Instantly share code, notes, and snippets.

View welblaud's full-sized avatar
🤔
solving something again

Honza Hejzl welblaud

🤔
solving something again
  • Husinec-Řež (Czech Republic)
View GitHub Profile
@welblaud
welblaud / RemoveRecursively.php
Last active February 17, 2023 16:01
Function for removing dirs and files recursivelly in PHP
<?php
function rrmdir(string $dirPath): bool {
array_map(static fn (string $filePath) => is_dir($filePath) ? rrmdir($filePath) : unlink($filePath), glob($dirPath . '/' . '*'));
return rmdir($dirPath);
}
@welblaud
welblaud / SignalCatching.php
Last active February 17, 2023 16:02
Signal catching in PHP
<?php
// turn on signal catching
pcntl_async_signals(true);
// handler
$sigHandler = static function(): void {
// do some cleanup
// report to user, whatever
// ...
exit(0);
};