I’m writing a parser for a digital statement my bank gives out and it works, but say in the case I want to let other people upload their statements to it. What is the best way to deal with the variable data after the script is done?
I’m initially using file($_FILES['uploadedfile']['tmp_name']) to get the file’s data. After the script is finished, is this temp file deleted? Or do I need to that myself?
For the variables, is unset() enough or do I have to go one step further?
Variables are stored in memory, and once the script is finished, the memory is freed and they are destroyed and cannot be recovered. There is no need to call
unset()on them as this happens implicitly when the script terminates.The temp files created by file uploads that appear in the
$_FILESarray should be deleted as soon as the script finished execution, but if you want to be doubly sure of this you can callunlink()on them.As long as you don’t store sensitive data in
$_SESSION, cookies, or anything else that explicitly has permanence, you should be alright.If you do need to hold some data on the server you could encrypt it using, for example, Mcrypt.