[PHP-NOTES] note 130503 added to function.register-shutdown-function
[email protected] ("Anonymous") Fri, 10 Oct 2025 13:37:53 +0000
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
Note the use of "by reference" in the use():
$aFilesToDelete=[];
register_shutdown_function(function() use (&$aFilesToDelete) {
foreach($aFilesToDelete as $sFile){
if(file_exists($sFile)) unlink($sFile);
}
});
...
rest of your code that adds to the aFilesToDelete array
...
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 81.133.43.69)
----
Manual Page -- https://php.net/manual/en/function.register-shutdown-function.php
Edit -- https://main.php.net/note/edit/130503
Del: integrated -- https://main.php.net/note/delete/130503/integrated
Del: useless -- https://main.php.net/note/delete/130503/useless
Del: bad code -- https://main.php.net/note/delete/130503/bad+code
Del: spam -- https://main.php.net/note/delete/130503/spam
Del: non-english -- https://main.php.net/note/delete/130503/non-english
Del: in docs -- https://main.php.net/note/delete/130503/in+docs
Del: other reasons-- https://main.php.net/note/delete/130503
Reject -- https://main.php.net/note/reject/130503
Search -- https://main.php.net/manage/user-notes.php